8000 Secondary axis does not show minor ticks. · Issue #14443 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Secondary axis does not show minor ticks. #14443
Closed
@Knusper

Description

@Knusper

Bug report

Bug summary

Matplotlib 3.1 introduced a new method for adding a secondary axes with Axes.axes.secondary_xaxis and Axes.axes.secondary_xaxis. However, the .minorticks_on() method does nothing on those axes.

Code for reproduction

I use the example provided in the gallery -- https://matplotlib.org/3.1.0/gallery/subplots_axes_and_figures/secondary_axis.html -- but modify it to show minor ticks.

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots(constrained_layout=True)
x = np.arange(0, 360, 1)
y = np.sin(2 * x * np.pi / 180)
ax.plot(x, y)
ax.set_xlabel('angle [degrees]')
ax.set_ylabel('signal')
ax.set_title('Sine wave')

def deg2rad(x):
    return x * np.pi / 180

def rad2deg(x):
    return x * 180 / np.pi

secax = ax.secondary_xaxis('top', functions=(deg2rad, rad2deg))
secax.set_xlabel('angle [rad]')

ax.minorticks_on()
secax.minorticks_on()

plt.show()

Actual outcome

Screenshot_2019-06-04_19-20-05

Expected outcome

The top axis is expected to have minor ticks.

Matplotlib version

  • Operating system: Linux 4.9.0-9-amd64 Fix autofmt_xdate() when using in conjunction with twinx() #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64 GNU/Linux
  • Matplotlib version: 3.1.0 (conda default channel)
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: Python 3.6.8 |Anaconda custom (64-bit)|

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

      0