Subplots | How to add master axis titles

I’ve created a subplot where all of the plots share the same x/y-axis type (Energy for the y-axis and voltage for the x-axis). I’d like to add a master axis title for the y- and x-axis (see the attached figure), but haven’t found a solution.

Is this capability not currently supported?

Is there any way to emulate the behavior I’m interested in?

Thank you in advance.

Hi @flores12,

The best way to accomplish this is to use annotations in paper coordinates. Here’s an example that I think does almost exactly what you want (https://plot.ly/python/text-and-annotations/#adding-annotations-with-xref-and-yref-as-paper)

Hope that helps!
-Jon

Hey @jmmease, thank you for the recommendation.

This works well, the only downside is that the text needs to manually placed and it doesn’t respond well to changes in the plot dimensions.

But otherwise, I’m happy with the results.

Raul

image

1 Like

Did plotly ever implement a solution?

Hi @jvdh,

Starting with Plotly 4.0.0 you can add master axis titles as x_title respectively y_title:

from plotly.subplots import make_subplots
fig = make_subplots(rows=2,
                    cols=2,
                    #print_grid=True,
                    vertical_spacing=0.085,
                    horizontal_spacing=0.085,
                    x_title='Your master x-title',
                    y_title='Your master y-title',
                    subplot_titles=('Subplot title1',  'Subplot title2', 
                                    'Subplot title3', 'Subplot title4')))

The function make_subplots() has the following parameters:

def make_subplots(
    rows=1,
    cols=1,
    shared_xaxes=False,
    shared_yaxes=False,
    start_cell="top-left",
    print_grid=False,
    horizontal_spacing=None,
    vertical_spacing=None,
    subplot_titles=None,
    column_widths=None,
    row_heights=None,
    specs=None,
    insets=None,
    column_titles=None,
    row_titles=None,
    x_title=None,
    y_title=None,
    **kwargs
)
three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online