Skip to content

Subplot font size is hardcoded to 16pt #985

Closed

Description

@jisaacso

See https://github.com/plotly/plotly.py/blob/master/plotly/tools.py#L1336. Large font leads to overcrowding when plotting multiple subplots with titles.

It would be better to have make_subplots accept a kwargs parameter like font_size=8 or, more general, to have a kwargs parameter like font=graph_objs.Font(size=8, color=...)

Activity

  1. jjnurminen commented on Apr 27, 2018

    @jjnurminen

    Seconded.

  2. rysktky commented on May 20, 2018

    @rysktky

    I guess you are talking about font size of subplot tiles?

    You guys probably already know how to update the fonts of subplots created by make_subplots,
    but it isn't probably the best convenient way like your suggestions, i might guess.

    and i also guess i might use the spacing option and margin to adjust the spaces.
    it looks like changing the fonts does not change the spacing??

    For now, i hope this example meets your expectation,
    though it will force you to have the same font for all subplot titles...

    fig = tools.make_subplots(rows=3, cols=2, 
                              subplot_titles=('trace1','trace2','trace3','trace4','trace5','trace6'))
    
    fig.append_trace(trace1, 1, 1)
    fig.append_trace(trace2, 2, 1)
    fig.append_trace(trace3, 3, 1)
    fig.append_trace(trace4, 1, 2)
    fig.append_trace(trace5, 2, 2)
    fig.append_trace(trace6, 3, 2)
    
    for i in fig['layout']['annotations']:
        i['font'] = dict(size=10,color='#ff0000')
    
  3. jjnurminen commented on May 21, 2018

    @jjnurminen

    You guys probably already know how to update the fonts of subplots created by make_subplots

    I had no idea. Tried googling for 'plotly subplot title font size' etc. but could not find a solution. I guess the key point here is that subplot titles are annotations.

    for i in fig['layout']['annotations']:
        i['font'] = dict(size=10,color='#ff0000')
    

    Yep, that works. Of course one can simply write i['font']['size'] = 10. Maybe this should be in the example gallery?

  4. jisaacso commented on May 22, 2018

    @jisaacso
    Author

    Same, I didn't realize that subplot titles are annotations.

    While it would still be nice to pass this in as a param to make_subplots() during initialization, this solves the problem for now, so I'll close. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions