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

Skip to content

added axis ticks and labels don't replace default labels #9253

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
gpetty opened this issue Sep 30, 2017 · 6 comments
Closed

added axis ticks and labels don't replace default labels #9253

gpetty opened this issue Sep 30, 2017 · 6 comments
Labels
status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action

Comments

@gpetty
Copy link

gpetty commented Sep 30, 2017

Bug report

Bug summary

Code that used to work flawlessly for replacing tick locations and labels on a log axis now seems to merely add to the default labels, so both now appear in the plot.

Code for reproduction


from matplotlib import pyplot as plt

# set the axis limits
xmin = -100   # min temperature to plot
xmax = 40    # max temperature
ymin = 100   # min pressure
ymax = 1000  # max pressure
plt.axis([xmin, xmax, ymax, ymin])

plt.semilogy()

# make lists of tick values and tick labels
plist = range(ymin,ymax,100)
plabels = []
for p in plist:
    plabels.append(str(p))

plt.yticks(plist,plabels)

x = [xmin, xmax]
y = [ymin, ymax]
plt.plot(x, y)
plt.show()

Actual outcome

untitled 2

# If applicable, paste the console output here
#
#

Expected outcome

There should be no overwriting of custom labels with the default scientific notation labels. It did work correctly about a year ago, but I cannot say what version of Matplotlib was being used at that time.

Matplotlib version

  • Operating System: Mac osx-64
  • Matplotlib Version: 2.0.2
  • Python Version: 2.7.12
  • Jupyter Version (if applicable): 4.3.0
  • Other Libraries:

conda install matplotlib

@tacaswell
Copy link
Member

This is an intentional change in 2.0 (http://matplotlib.org/users/dflt_style_changes.html#logformatter-labeling-of-minor-ticks) that the default log ticking now labels minor ticks.

duplicate of #8027
duplicate of #8386
duplicate of #8517

@gpetty
Copy link
Author

gpetty commented Sep 30, 2017

Thank you for the clarification. It may not be a bug, but it significantly increases the complexity of doing simple things. The students I instruct to use simple pyplot functions for their lab assignments did not previously need to know about axes and their methods. Now they apparently will, if I'm understanding the available workarounds.

Could there not be a function plt.yminorticks('none'), option plt.semilogy(yminorticks='off'), or similar?

Edit: Even I, a relatively experienced Pyplot user, have not yet been able to figure out a workaround, complex or otherwise.

@anntzer
Copy link
Contributor

anntzer commented Sep 30, 2017

I think it would make sense for plt.x/yticks to clear the minor ticks (unless I'm mistaken, it doesn't appear like you can set the minor ticks using plt.xticks anyways, so they're not likely to be correct -- in other words, if you are using plt.xticks you are implicitly saying "I don't care about minor ticks").
Note that I'm specifically only talking about plt.xticks, not any of the Axes methods, which should maintain their documented behavior).

Reopening to discuss whether this would be a worthwhile approach.

@gpetty
Copy link
Author

gpetty commented Sep 30, 2017

Someone on stackexchange just pointed out that there's a plt.minorticks_off() function that I hadn't previously found. I'm surprised this wasn't mentioned in any of the related bug reports that I viewed.

@shamichatterjee
Copy link

This is still an issue in Python 3.6.6 / Matplotlib 2.2.3. Thank you for the pointer to plt.minorticks_off() - I ran into the same problem, and I second the sentiment that user-specified x/yticks should always take precedence over default labels.

@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 19, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2023
@rcomer rcomer added the status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. label May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action
Projects
None yet
Development

No branches or pull requests

5 participants