question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating layout of specific subplot

See original GitHub issue

Hi there. I’ve spent the past few hours browsing the plotly documentation and stackoverflow to solve my problem, but I find nothing.

What I want to do, is update the layout of a specific subplot. If this is not possible, then updating all of them is fine as well.

I’ve tried -> https://plotly.com/python/subplots/ In the form of fig.update_xaxes(title_text="xaxis 1 title", row=1, col=1) But this did not work.

I’ve also tried to update the layout by trying to set xaxis2, as some Stack Overflow users suggested, this just gave me a key error. Maybe this was an old functionality?

From -> https://plotly.com/python/3d-axes/ I’ve tried: fig.update_layout(scene = dict( xaxis_title='X AXIS TITLE', yaxis_title='Y AXIS TITLE', zaxis_title='Z AXIS TITLE'), width=700, margin=dict(r=20, b=10, l=10, t=10))

This works, however it only updates the first subplot I have.

Essentially this is the code I have for adding the trace objects.

Screenshot_1

Then this is my attempt at editing the axes, yet this only updates the first plot.

Screenshot_2

This is my result, and it’s really frustrating because I just want my axes labeled…

result

As you can probably see, the first plot is nicely zoomed out as well, however I have the exact same problem that when I update the layout, it only updates the first plot instead of all of them.

This is my make subplots code. While I’m glad that there’s a subplot_titles argument, is there no functionality to do the same for the axes of the plots?

Screenshot_3

In another issue I saw one of the developers of Plotly reply that update_xaxes, and update_yaxes is the way to do this, but as I mentioned before this did not do anything for me. No errors, just the plots and no updated labels.

If anyone’s knowledgeable in this, then thanks in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostcommented, May 19, 2020

Ah, I’m sorry our documentation is giving you such a hard time! The problem here is that .update_xaxes() and .update_yaxes() operate on 2d charts, not 3d charts like yours. You’ll have to use update_scenes which I now see isn’t really anywhere in our docs, and is something we’ll work on shortly (cc @emmanuelle @jdamiba)

I should add that the subplot “titles” themselves are actually annotations, stored in layout.annotations and not actually indexable by row/col unfortunately, so you have to set those correctly in the make_subplots() call otherwise they’re pretty tricky to update.

You know, the thought passed through my mind that it could’ve been only applicable to 2D plots (-:

In any case… I got it to work now. Thanks a bunch, Nicolas! Awesome of you to reply so quickly.

If anyone gets to this topic somehow with the same problem here’s how I fixed it.

Screenshot_4

0reactions
vontomarcommented, May 10, 2022

You can just do f.update_polars(..., row=3, col=4), there is no need to use for_each_polar.

Hi Nicolas Thank you so much, This works brilliantly. Best wishes, Martin

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the correct way to set layout properties for each subplot?
For updating subplots, you can use fig.update_xaxes and fig.update_traces which take a row and col parameter so that you can modify each subplot...
Read more >
update specific subplot axes in plotly - python - Stack Overflow
I'm tring to plot a subplots with plotly library, but can't figure out how to reference a specific subplots' axis to change its'...
Read more >
Plotly - Subplots and Inset Plots - Tutorialspoint
The Layout of figure is further configured by specifying title, width, height, etc. using update() method. fig['layout'].update(height = 600, width = 800s, ...
Read more >
How to Create Subplots in Plotly Python - Life With Data
To create subplots in Plotly, we use the make_subplots function from plotly.subplots module. Let's read a dataset to work with
Read more >
Python Plotly - Subplots and Inset Plots - GeeksforGeeks
The subplots method provides a way to plot multiple plots on a single figure. ... fig[ 'layout' ].update(height = 600 , width =...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found