-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fix xkcd context #9521
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
fix xkcd context #9521
Conversation
I do not understand how either the change to the context manager nor this change fixes it. |
Before it was just setting the rcParams to the new xkcd values and not passing them to the context. I don't understand how it worked before ;-) |
Ah, I understand. Before the clean up of This PR fixes the case of a context manager, but I suspect breaks if you just call plt.xkcd()
fig, ax = plt.subplots()
... |
Um yeah I guess so. I find this a strange function in that it passes parameters to a style. |
I’d actually propose an xkcd style and deprecating this function. If folks want to monkey with the randomness of the lines they can call the style and then do so directly with the rcparams. I’m too dense to know how to make this work as both a context and directly changing the rcParams. |
So you just need to add a call to |
Ok that’s easy. |
xkcd style will not work because the rcparams machinery is messed up (or pick a less strong qualifier) #6157 |
from matplotlib import patheffects
context = rc_context()
context.__enter__() yields
|
Bah, we were doing something way too complex.
works (I tried it!). |
I thought thats what I did ? |
... sorry, not paying attention. back to the drawing board. |
Yeah, that doesn't work for @tacaswell case... |
Sorry to be dense about the context management. I can close this PR and let you work on it if easier. FWIW, @tacaswell case isn't actually documented or tested anywhere! Its implied in the docstring. |
this actually works in both cases
(except that it needs a backport of contextlib.ExitStack (or similar) on AncientPython, e.g. https://pypi.python.org/pypi/contextlib2/0.5.5). Basically we want to enter the rc_context but return another context that does nothing on enter but pops the rc_context on exit. ExitStack exactly provides that functionality. As pointed out by @tacaswell #8962 indeed broke backcompat for whoever was using |
Is this because Is it possible to have a style-sheet parser fcn that reads a string from |
OK, I suggest this change is consistent w/ the most documentation for now. I suggest a way forward is to parse style sheets for strings that have patheffect calls, but to explicitly call |
Closing in lieu of #9603 |
Thanks for your work on this @jklymak ! |
No problem - @anntzer solution is very cool! |
PR Summary
Fixes xkcd context so that one can do (as per #9520):
PR Checklist