Skip to content

secondary_xaxis doesn't seem to use formatters #15621

@fmikulasch

Description

@fmikulasch

Bug report

secondary_xaxis (and secondary_yaxis?) doesn't seem to use formatters.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

fig, axs = plt.subplots(figsize=(0.6*4,0.6*3))
y = np.random.rand(10)
x = np.linspace(30,200,num=10)

p = plt.plot(x, y, marker='o', markersize=3)
plt.xscale("log")

def m2rho(m):
    return 1 / m * 1000

def rho2m(rho):
    return 1 / rho * 1000

secax = axs.secondary_xaxis('top', functions=(m2rho, rho2m))

from matplotlib.ticker import ScalarFormatter, NullFormatter
for axis in [axs.xaxis, secax.xaxis]:
    axis.set_major_formatter(ScalarFormatter())
    axis.set_minor_formatter(NullFormatter())
axs.set_xticks([50, 100, 200])
secax.set_xticks([20,10,5])

plt.tight_layout()
plt.show()

Actual outcome

Figure_1

Expected outcome

The top axis should be formatted similarly to the bottom (first) x-axis.

Matplotlib version

  • Operating system: Ubuntu 18.04
  • Matplotlib version: 3.1.1
  • Matplotlib backend: Qt5Agg
  • Python version: 3.7.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy