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
Linestyle pattern depends on current style, not style set at creation #6592
Comments
When |
There are a bunch of oddities here. Notice that the font size seems On Thu, Jun 16, 2016 at 1:53 AM, Eric Firing notifications@github.com
|
Any of the draw-time consultations of checking for the internal classic style need to turn into caching that on the artists 😞 |
To say it's surprising is an understatement. At a bare minimum, this needs to be in bold print with the docs for I recognize how much of a pain in the ass it would be to fix this completely--but I feel confident in saying that having these 3 possibilities is a terrible user experience (though hopefully not frequently encountered). If we agree that in principle that |
On 2016/06/16 5:20 AM, Ryan May wrote:
If I understand you correctly, then I don't agree with this in |
Well, I would have expected the following to work from matplotlib import style
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
with style.context('classic'):
ax.plot([1, 2, 3], linestyle='dashed')
with style.context('default'):
ax.plot([2, 4, 6], linestyle='dashed')
fig.savefig('mixed.png') But I now see the semantics of it (especially with property cycles) are a bit complicated. So in lieu of that, is there any mechanism that gives something like: fig = plt.figure()
fig.stylesheet = 'classic' What I'm running up against is the problem that styles are a global state, and I really don't want to be mucking with global state in tests. |
Oh, and I just found this in the stylesheet docs: >>> import numpy as np
>>> import matplotlib.pyplot as plt
>>>
>>> with plt.style.context(('dark_background')):
>>> plt.plot(np.sin(np.linspace(0, 2 * np.pi)), 'r-o')
>>>
>>> # Some plotting code with the default style
>>>
>>> plt.show() So whoever wrote this intended it to work as I expected.... |
I agree; I have never liked rcParams, with its massive global state. It is particularly dangerous as a mechanism for controlling local state, flipping settings back and forth. I suspect we can figure out better ways of handling this, but not as modifications to 2.0. |
Well, we have a problem for 2.0 since the stylesheets will IMO see a lot more use as people fall back to 'classic' for cases like this. The fact that our own docs are wrong on this really bothers me. |
@dopplershift it definitely should work as you expected. |
I'm probably over-reacting because of my dislike for rcParams; I will defer to @tacaswell's judgment. It seems like the question is whether all factors influenced by rcParams can be frozen based on the rcParams values at the time of artist creation, and the answer is "no", because layout is only finalized when the figure is drawn, so it has to depend on |
with #6710 I do not think you can get around the remaining difference between test1 and test2 because the default savefig dpi should be looked up at save time, not at figure creation time. |
When scaling the dash pattern by the linewidth do the scaling at artist creation / value set time rather than at draw time. closes matplotlib#6592
When scaling the dash pattern by the linewidth do the scaling at artist creation / value set time rather than at draw time. closes matplotlib#6592
When scaling the dash pattern by the linewidth do the scaling at artist creation / value set time rather than at draw time. closes matplotlib#6592 closes matplotlib#6588 closes matplotlib#6590 Closes matplotlib#6693 closes matplotlib#5430
This is on 2.x (both the beta and current git HEAD) and confused me for the longest time:
So the first
save_fig()
gives the classic style as expected:And the last
save_fig()
gives the new defaults:But for some reason the 2nd
savefig()
, where the figure is created with the classic style, but is written outside the context manager gives a figure that looks like classic, except the dash pattern different:This seriously confused me for the afternoon--it wreaks havoc with my tests where I'm now setting the stylesheet to classic inside the test. When pytest-mpl saves the test outside the context manager (and outside my test function) I get some weird abomination.
The text was updated successfully, but these errors were encountered: