Can't add subplot titles/horizontal spacing to 3d subplots
See original GitHub issueI’ve got this:
fig = tools.make_subplots(
rows = 2,
cols = 2,
specs = [
[{'is_3d': True}, {'is_3d': True}],
[{'is_3d': True}, {'is_3d': True}]
],
horizontal_spacing = 0.001,
vertical_spacing = 0.000001
)
and I’m unable to add this:
subplot_titles = ('title1', 'title2', 'title3', 'title4'),
I’m running 1.12.3. Here’s the error when I try to add just one title, and it’s the same if I do four:
Traceback (most recent call last):
File "wildhorsesbf.py", line 514, in <module>
subplot_titles = ('srbfb'),
File "C:\Python27\lib\site-packages\plotly\tools.py", line 1312, in make_subplots
plot_titles.append({'y': subtitle_pos_y[index],
IndexError: list index out of range
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
Improve subplot size/spacing with many subplots
No matter how big I allow the figure to be, the subplots always seem to overlap. My code currently looks like import matplotlib.pyplot...
Read more >2D and 3D axes in same figure - Matplotlib
This example shows a how to plot a 2D and 3D plot on the same figure. A tale of 2 subplots. import matplotlib.pyplot...
Read more >plotly.subplots.make_subplots — 5.11.0 documentation
Space between subplot columns in normalized plot coordinates. ... (default None)) – Title to place below the bottom row of subplots, centered horizontally....
Read more >How to set the spacing between subplots in Matplotlib in ...
Using tight_layout() method to set the spacing between subplots. The tight_layout() method automatically maintains the proper space between ...
Read more >matplotlib - 2D and 3D plotting in Python
This line configures matplotlib to show figures embedded in the notebook, # instead of opening a new window for each figure. More about...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Xirious I just ran into this issue and used a quick (hack-y) workaround based on the insight from @Galadirith. Since subplot titles are generated as annotations, creating an equivalent figure without 3D subplots and then copying the annotations into the target figure seems to work. Don’t know about solving the spacing issue.
Modifying the 3D-subplots example (https://plot.ly/python/3d-subplots/):
@jjc12 @eulerreich I have a hacky workaround, add the kwarg
shared_xaxes=True
.It doesn’t actually make the xaxis shared (I don’t know if that is even possible in 3D) but does get rid of the error and make the titles appear for me.
This issue comes from this block of code (
plotly/tools.py#L1225-L1235
), so I figured if I could make it take the other conditional path it might work and it did.My guess is that for 3D plots the
list_of_domains
is not ever populated. There seems to be a way to avoid using themake_subplots
method (https://plot.ly/python/subplots/#multiple-subplots). In that example its for 2D plots but I guess you could to the same for 3D plots. Themake_subplots
adds afig['annotations']
entry onplotly/tools.py#L1267
, so I guess in theory you could manually add the titles, but thats probably quite fiddly.I hope this workaround works for you 😄