-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix use() so that it is possible to reset the rcParam. #1028
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
Conversation
you accidentially added a swap file with this commit. |
I strongly oppose this, as explained in my reply to your original email. |
I noticed the .swp commit (no idea how that happened). This is a new set of commits that adds a 'force' parameter to use and uses this in switch_backend(). |
Sorry to be fussy, but I really think the reload needs to be moved from switch_backends to use. In use, if the module was already loaded, then set a flag; and at the end of use, if that flag is set, do the reload. Otherwise there is a mismatch between the state of the system and the rcParams. Am I missing something here? |
I guess not. It seemed like this would have made switch_backend() largely superfluous, but I guess it still has all the pylab setup code. This is probably yet more clean. |
This seems to be working alright. One more question: I think now I'd like to add a flag that controls whether switch_backend() closes the old figures. Thoughts? |
Why would you want to do that? What happens if an old window gets redrawn, or something gets plotted to it, after you have made the switch? Why do you want to do all this switching in the first place? It seems like it is opening up a big can of worms, so it needs a compelling use case. |
@@ -920,23 +920,37 @@ def use(arg, warn=True): | |||
loaded. In certain black magic use cases, e.g. | |||
:func:`pyplot.switch_backends`, we are doing the reloading necessary to | |||
make the backend switch work (in some cases, e.g. pure image | |||
backends) so one can set warn=False to supporess the warnings. | |||
backends) so one can set warn=False to suppress the warnings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring still needs work to explain exactly what warn and force do.
@efiring, you haven't seen the ipython notebooks, have you? This is the driver for it, to be able to switch back and forth between two backends. |
It seems technically possible to continue to run a gui figure in the background while using image figures elsewhere. I view this as something that is usually a really bad idea, but to have a hook to do it if you claim to know what you are doing. I'd document it as so. In the same vein of being unsafe, I had started to document the kwargs to use(), but had stopped because I didn't want to encourage anyone to use them. I guess it may be better to be explicit about their danger in a documented fashion. |
it seems that we end up closing down the event loop, so the not-closing feature is better left as a thought experiment. I'll update the docstrings. |
On 2012/07/20 11:28 AM, Benjamin Root wrote:
I'm vaguely familiar with it. I think I tried one briefly a while back. |
Switching between the image and GUI backends allows you to be able to work with interactive and inline figures within a single notebook. Without switching backends, you have to choose. |
Add an option to use() that allows forcing the configuration change which also reloads the module as necessary. Fix and slightly refactor switch_backend() to make use of this functionality.
I see no other reason to withhold this PR. It does fix a definite bug. There are some other issues, but they probably should be addressed in a different PR. |
Fix use() so that it is possible to reset the rcParam.
With this change, the warn argument acts as a way to ignore the warning
and force the rcParam change. This allows switch_backend() to actually
function again.