serhii.net

In the middle of the desert you can say anything you want

02 Jun 2022

Plotly updating graphs

Reading Creating and updating figures in Python.

  1. All of these are equivalent (code from link):
fig.update_layout(title_text="update_layout() Syntax Example",
                  title_font_size=30)

fig.update_layout(title_text="update_layout() Syntax Example",
                  title_font=dict(size=30))


fig.update_layout(title=dict(text="update_layout() Syntax Example"),
                             font=dict(size=30))

fig.update_layout({"title": {"text": "update_layout() Syntax Example",
                             "font": {"size": 30}}})

fig.update_layout(title=go.layout.Title(text="update_layout() Syntax Example",
                                        font=go.layout.title.Font(size=30)))
  1. Introducing linebreaks: <br> and <br /> work, <br/> doesn’t. 1
  1. Margins in graph: Setting graph size in Python
fig.update_layout(margin=dict(l=20, r=20, t=20, b=20))

And I just want to mention the very special design decision to have arguments named tickfont and title_font (with underscore), in the same function, getting identical arguments.


  1. r - How to add line breaks to plotly hover labels - Stack Overflow ↩︎

Nel mezzo del deserto posso dire tutto quello che voglio.