Skip to content

Ticklabel format not preserved after editing plot limits #6276

Closed

Description

@peytondmurray

Version: 1.5.1, Windows 7, using QT5 backend. Not tested on linux yet. After setting the format of an axis to use use scientific notation,

ticklabel_format(style='sci', axis='y', scilimits=(0,0))

changing the limits of the plot using the green checkbox widget in the NavigationToolbar will remove the scientific notation formatting that was just set. This would be a huge convenience for users who use scientific notation and want to work with plots interactively. Example:

import matplotlib
matplotlib.use("Qt5Agg")
from numpy import *
from matplotlib.pyplot import *
from numpy.random import uniform

npts = 1000

x = uniform(-100, 100, npts)
y = 1000*sin(x)*cos(x**2)

plot(x, y)
ticklabel_format(style='sci', axis='both', scilimits=(0,0))

show()

Activity

  1. added this to the milestone on Apr 7, 2016
  2. tacaswell commented on Apr 8, 2016

    @tacaswell
    Member

    It is the set_*scale calls which remove the formatting.

  3. added 2 commits that reference this issue on Apr 8, 2016
    eed7e69
    fd799a8
  4. self-assigned this
    on Apr 8, 2016
  5. modified the milestones: , on Apr 8, 2016
  6. gepcel commented on Apr 24, 2016

    @gepcel
    Contributor

    I think this might be relevant.

    plt.plot(1, 10000, 2, 20000, 'ro')
    ax = plt.gca()
    ax.yaxis.set_major_formatter(mpl.ticker.ScalarFormatter(useMathText=True))
    ax.ticklabel_format(scilimits=(-3, 3))  # put after 'set_major_formatter', scilimits works
    plt.show()

    works fine. But if ticklabel_format is put before set_major_formatter, it doesn't work.

    plot(1, 10000, 2, 20000, 'ro')
    ax = gca()
    ax.ticklabel_format(scilimits=(-3, 3))   #put before 'set_major_formatter', scilimits doesn't work.
    ax.yaxis.set_major_formatter(mpl.ticker.ScalarFormatter(useMathText=True))
    plt.show()
  7. added a commit that references this issue on May 22, 2016
    fe05b44
  8. added a commit that references this issue on Jul 24, 2016
    8681601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions