8000 Tick label padding on first y-axis changes when adding a second y-axis · Issue #4346 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Tick label padding on first y-axis changes when adding a second y-axis #4346
Closed
@breedlun

Description

@breedlun

When I have just the right set of commands, the tick label padding on the first y-axis changes when I add a second y-axis. Here are my minimal working examples.

This set of commands

import matplotlib as mpl
import matplotlib.pyplot as plt

fig = plt.figure()
ax1 = plt.subplot()
ax1.plot(range(2),range(2))
ax1.yaxis.set_tick_params(which = 'major', direction = 'out', \
    labelsize = mpl.rcParams['font.size'], size = mpl.rcParams['ytick.major.size'])
fig.savefig('No_Issue1.png')

produces a figure that looks fine to me:
no_issue1

This set of commands,

fig = plt.figure()
ax1 = plt.subplot()
ax1.plot(range(2),range(2))
ax2 = ax1.twinx()
fig.savefig('No_Issue2.png')

also produces a figure that looks fine, even after adding a second y-axis:

no_issue2

This set of commands

fig = plt.figure()
ax1 = plt.subplot()
ax1.plot(range(2),range(2))
ax1.yaxis.set_tick_params(which = 'major', direction = 'out', \
    labelsize = mpl.rcParams['font.size'], size = mpl.rcParams['ytick.major.size'])
ax2 = ax1.twinx()
fig.savefig('Issue.png')

however, messes with the tick label padding on the first y-axis:

issue

Apparently, the following commands

ax1.yaxis.set_tick_params(which = 'major', direction = 'out', \
    labelsize = mpl.rcParams['font.size'], size = mpl.rcParams['ytick.major.size'])
ax2 = ax1.twinx()

do not play nice together.

In case it matters, I am on matplotlib 1.4.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0