Skip to content

Shortcut for moving the axis tick labels to the right side of a set of subplots when sharey=True? #8188

Closed
@naught101

Description

@naught101

With subplots, the axis tick labels are on the left, and it's quite hard to move them to the right:

nrows = 4
ncols = 3
labels = ['One', 'Two', 'Three', 'Four']
fig, axes = subplots(nrows, ncols, sharey=True, sharex=True)
for i, label in enumerate(labels):
     axes[i, 0].set_ylabel(label)

     [l.set_visible(False) for l in axes[i, 0].get_yticklabels()]
     axes[i, -1].yaxis.tick_right()
     axes[i, -1].yaxis.set_visible(True)

figure_1

It took me ages to work this out, and it feels like there should be a simpler way. Possibly I'm missing something, but if not, it would be nice to have a few new parameters to subplots(), perhaps:

yaxis = ['left', 'right']  # move the whole axis, label, ticks, tick labels
yticks = ['left', 'right']  # Just move the ticks and labels
ylabel = ['left', 'right']  # Just move the axis titles to the right

And it would be nice to have all of these available for the xaxis too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesDocumentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions