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

ScalarFormatter.set_powerlimits documentation seems inconsistent · Issue #15376 · matplotlib/matplotlib · GitHub

Repository navigation

ScalarFormatter.set_powerlimits documentation seems inconsistent #15376

Closed

Description

Bug report

Documentation says:

set_powerlimits(self, lims)[source]
Sets size thresholds for scientific notation.
(min_exp, max_exp)
A tuple containing the powers of 10 that determine the switchover threshold. Numbers below 10**min_exp and above 10**max_exp will be displayed in scientific notation.

However

    sFormatter = matplotlib.ticker.ScalarFormatter(useOffset=False, useMathText=True)
    sFormatter.set_powerlimits((-2, 2))
    plt.plot([120,130,140],[0.03,0.05,0.08])
    plt.gca().xaxis.set_major_formatter(sFormatter)
    plt.gca().yaxis.set_major_formatter(sFormatter)

does use scientific notation on the y axis but not the x axis. The the correct description of the actual behaviour seems to be

A tuple containing the powers of 10 that determine the switchover threshold. Numbers with absolute values below 10**(min_exp+1) and above 10**(max_exp+1) will be displayed in scientific notation.

Or it is a bug (would make more sense if the original description were correct).

Activity

  1. ImportanceOfBeingErnest commented on Oct 3, 2019

    Member

    A confusing bit is that you are using the same formatter for both axes. If using a dedicated formatter per axis it would give

    import matplotlib.ticker
    import matplotlib.pyplot as plt
    
    sFormatter1 = matplotlib.ticker.ScalarFormatter(useOffset=False, useMathText=True)
    sFormatter1.set_powerlimits((-2, 2))
    
    sFormatter2 = matplotlib.ticker.ScalarFormatter(useOffset=False, useMathText=True)
    sFormatter2.set_powerlimits((-2, 2))
    
    plt.plot([120,130,140],[0.03,0.05,0.08])
    plt.gca().xaxis.set_major_formatter(sFormatter1)
    plt.gca().yaxis.set_major_formatter(sFormatter2)
    
    plt.show()
    

    Still, the sentence in the documentation remains incorrect (or at least not detailed enough), as seen from the y axis.

  2. anntzer commented on Oct 4, 2019

    Contributor

    As a general rule a single formatter instance cannot be used across multiple axises --- though #13482 fixes that :)

  3. added this to the v3.3.0 milestone on Oct 5, 2019
  4. timhoffm commented on Jun 8, 2020

    Member

    Reusing formatters is off-topic.

    The actual issue is a documentation issue. IMHO it's not a bug, but one has to think about the limits in the right way, see #17590.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL