Subplot titles not showing for Surface plots

I want the subplots to have separate titles and a figure title. It should be as simple as supplying subplot_titles=('Plot 1', 'Plot 2', 'Plot 3', 'Plot 4') when creating the figure but that doesn’t seem to work. To test it I copied the code from 3D Surface Subplots Example and added the line mentioned above and in subplots example when creating subplots but it returns an error:

IndexError: list index out of range

So do the 3D plots not support subplot titles?

Is there a way to do hack using annotations? From my understanding they are for data points not plots.

Thanks!

2 Likes

I am having the same issue, it looks like it’s not possible to add subplot titles for 3d subplots

import plotly as py
fig=py.tools.make_subplots(rows=2,cols=2,
    subplot_titles=('x','x','x','x'),
    specs=[[{'is_3d': True}, {'is_3d': True}], [{'is_3d': True}, {'is_3d': True}]])

here is the error I get:

line 1330, in make_subplots
plot_titles.append({‘y’: subtitle_pos_y[index],
IndexError: list index out of range

This is my workaround using annotations, I remove the “subplot_titles” argument from the make_subplots function:

fig=py.tools.make_subplots(rows=2,cols=2,
        specs=[[{'is_3d': True}, {'is_3d': True}], [{'is_3d': True}, {'is_3d': True}]])

and I use the corresponding scene with annotation.
remember subplot scene names are scene1, scene2, …

fig['layout']['my scene name'].update(annotations=[dict(z=40, text='my title', showarrow=False)])

You can pass proper x,y, z values based on your plot.
The final result will be something like this:

1 Like

Hi,
Thank you for this answer.

However, I can not make it work.

Could you please show a full example ?
Thank you very much for your help,

Best,
Pauline Maury Laribiere

Hi All,

Subplot titles for 3d subplots will be working in plotly.py version 4. You can try out the future version 4 behavior in version 3.10 by starting your notebook/script with the following future import

from _plotly_future_ import v4_subplots

Hope that helps,
-Jon