Skip to content

Incorrect ylabel placement in twinx #1608

Closed
@goyodiaz

Description

@goyodiaz

The ylabel of the new axes is not vertically centered and sometimes it overlaps yticklabels. This happens in recent development versions but not in 1.2.0.

This script shows the issue:

#!/usr/bin/env python

import matplotlib as mpl
mpl.use('agg')
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(100)
y1 = x
y2 = 1. / (x + 1)

plt.plot(x, y1)
plt.ylabel('Y axis #1')
plt.twinx()
plt.plot(x, y2)
plt.ylabel('Y axis #2')
plt.savefig('test.png')
plt.close()

This is the ouput with mpl 1.2.0 (correct):
test_1 2 0

And with 1.3.x (incorrect):
test_1 3 x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions