Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Log-scale ignores Formatter #8517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lkluft opened this issue Apr 20, 2017 · 3 comments
Closed

Log-scale ignores Formatter #8517

lkluft opened this issue Apr 20, 2017 · 3 comments

Comments

@lkluft
Copy link

lkluft commented Apr 20, 2017

Bug report

Bug summary
Logarithmic scaling seems to break the label formatting.

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib import ticker
import numpy as np


p = np.linspace(1000, 500, 100)
T = np.linspace(300, 200, p.size)


fig, ax = plt.subplots()
ax.plot(T, p)
ax.set_yscale('log')
ax.yaxis.set_major_formatter(ticker.StrMethodFormatter('{x:.3f}'))

plt.show()

The issue is reproducible using different Formatters (e.g. FuncFormatter, ...).

Actual outcome
outcome

Expected outcome
I would expect the axis to use the passed Formatter like the linear scaled axis does:

expected

Matplotlib version

  • Operating System: macOS Sierra (10.12.4) | Debian GNU/Linux 8.6
  • Matplotlib Version: 2.0.0
  • Python Version: 3.6.1

Matplotlib was installed from the conda-forge channel.

Thanks for your great work!

/Lukas

@tacaswell
Copy link
Member

It is using your formatter for the major ticks (the 1000.000 at the top), but log scale now also turns on minor ticks by default (see http://matplotlib.org/users/dflt_style_changes.html#logformatter-labeling-of-minor-ticks ).

You will need to either turn off the minor formatters or also set them to what you want.

@tacaswell
Copy link
Member

Closing this as not a bug, where would you have looked for documentation on this?

@lkluft
Copy link
Author

lkluft commented Apr 20, 2017

Thank you for the quick response! Setting the minor formatter as well leads to the wanted result.

I just did not realise that the ticks in the log-scaled version are minor. Being aware of this, the solution (setting minor_formatter) seems natural.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants