Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

tight_layout + lots of subplots + long ylabels inverts yaxis #8062

Copy link
Copy link
Closed
@NelleV

Description

@NelleV
Issue body actions

When plotting a lot of subplots (here 6), with long y-labels and tight_layout, the y-axis is reverted.
In this example, it is particularly striking as I am plotting histograms.

import matplotlib.pyplot as plt
import numpy as np

alphas = [0.001, 0.1, 1, 10, 1000, 10000]
X = np.random.randn(len(alphas), 1000)

fig, axes = plt.subplots(nrows=len(alphas),  ncols=2)
fig.set_tight_layout(True)
for i, alpha in enumerate(alphas):
    ax = axes[i, 0]
    ax.hist(X[i])
    ax.set_xlabel("Number of features", fontweight="bold")
    ax.set_ylabel("Number of genes", fontweight="bold")

    ax = axes[i, 1]
    ax.plot(sorted(X[i]))
    ax.set_ylabel("Number of genes", fontweight="bold")

mpl_bug

Expected outcome

Removing the tight layout, the labels collapse, but at least the plots are oriented the correct way.

mpl_bug_wo_tight_layout

Matplotlib should either raise a proper error raise a proper warning, or plot the histograms in the proper order.

Matplotlib version

Matplotlib 2.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.