FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Log-scale ignores Formatter · Issue #8517 · matplotlib/matplotlib · GitHub

Repository navigation

Log-scale ignores Formatter #8517

Closed
Closed

Description

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

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

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

Activity

  1. tacaswell commented on Apr 20, 2017

    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.

  2. tacaswell commented on Apr 20, 2017

    Member

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

  3. lkluft commented on Apr 20, 2017

    Author

    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

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


      Back | FazBrowse Home | New Git URL