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
xticks/yticks default behaviour #5937
Comments
You should really be using |
Hi @tacaswell, thanks. Firstly, can you point me somewhere so I understand what you said above? What is it about having users that makes it more appropriate to use the I am really interested in contributing to Matplotlib. Is the procedure that once things are posted here and are assigned a tag, e.g. 'Difficulty: Easy', anyone can have a go at fixing/implementing it? |
I touch on the axes methods versus pyplot in my Anatomy of Matplotlib What I don't talk about here is that when writing code for yourself, you As for rules & procedures, there aren't really any, but we do have a guide Cheers! On Fri, Jan 29, 2016 at 6:51 AM, Ferdinand van Wyk <notifications@github.com
|
@WeatherGod Thanks, that makes sense now. Are we agreed that both the I've looked into it and once fixed I'll set up a PR for review. |
Hi, I've tried implementing this so that Executing the code for the test plot above (for the most up to date Master branch): import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,1)
fig, ax = plt.subplots()
ax.plot(x, x**2)
plt.show() I get the following plot: However calling x = np.linspace(0,1)
ax.plot(x, x**2)
ax.set_xticks(ax.get_xticks())
plt.show() Running >> ax.get_xticks()
array([-0.2, 0. , 0.2, 0.4, 0.6, 0.8, 1. , 1.2]) Note: I'm not finding the same for the release version. Running the above code on 1.5.1 gives: >> ax.get_xticks()
array([0. , 0.2, 0.4, 0.6, 0.8, 1. ]) This may even constitute a new ticket since this seems like a bug as opposed to a feature request. Does anyone have any ideas? I'm new to the Matplotlib source code so it may take a while for me to find the issue here. Ubuntu 14.04 LTS |
This is intended behavior. As part of the 2.0 style over-haul we by default added padding to the data limits to improve how the plots look. The ticks are located via a Calling When After a bit more consideration, I am not sure what the behavior of The convention that mpl (mostly) follows is that |
Thanks for the explanation @tacaswell, I thought I was going slightly crazy seeing subtly different plots between dev and release branches. I did think the extra padding helped frame the plots a bit better so if that's the default behaviour from now on then the functionality for setting tick defaults moves to the application side. It's a shame, however since I really wanted to avoid adding logical checks in loops producing 1000's of plots or duplicating code to have two different versions depending on user set options. Thanks for taking the time to help. I think we can close this ticket now and I'll find some other ticket to start my Matplotlib contributions! |
I want to be able to set the
xticks
oryticks
based on user input, but I can't seem to do this without invoking anif
statement in order to use the default behaviour.To get the default
xticks
for example, you can run:However, if I want a user-set variable to set the
xticks
, I have to do this:Since the code
plt.xticks(None)
gives the following error:Could the
plt.xticks
andplt.yticks
functions allow the passing ofNone
to retrieve default behaviour, or is there some way of getting the default ticks while still passing a variable?The text was updated successfully, but these errors were encountered: