-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Feature request - make it simpler to use full OO interface #1094
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
Comments
It would probably be cleaner this way. Currently, pyplot.figure() invokes the |
Setting self.canvas = None Which is evidenced by: In [1]: from matplotlib.figure import Figure
In [2]: fig = Figure()
In [3]: print fig.canvas
None One way to work around this is to retrieve the default backend in the Is there something deeper I am missing? |
@dmcdougall - this is exactly what I mean, and I believe it would make it a lot easier for people to use this API. |
So I tried this out, and it seems to work ok. I can't say anything for |
This might have worked if carefully restricted to non-interactive backends. I think it requres some careful thought and experimentation, though. It may be that the way to handle it is via a kwarg to the Figure constructor, explicitly designating a non-interactive backend; or maybe in the code as you had it, attaching the canvas to the figure upon Figure initialization would be done only if the default backend is non-interactive. All of the messy figure management machinery is needed only for screen display, not for savefig, I believe. |
@efiring Do you think we can find a way to implement this issue without changing the interactive workflow? I have some spare time on the next few weeks and would like to work on that. |
You are certainly welcome to try. I'm out on a ship until mid-Nov., and then busy into December, so I probably won't be much help. If you can come up with something that makes the whole Figure/Canvas dance simpler and easier to understand at the lowest code level as well as at the user level--and that doesn't break anything--that will be very good. |
I'll sure give it a try. |
matplotlib-devel is a good place to reach other developers: https://sourceforge.net/mailarchive/forum.php?forum_name=matplotlib-devel |
@berr I've been working on an alternative solution to this, and currently have an implementation illustrating some degree of success. That said, I would be interested to see if you come up with a similar approach. Do you have a branch I can take a cheeky fork of? |
@dmcdougall Not yet. I'm planning to start this on the next week. Since you've already started, I can use your work as a starting point or even just continue it. Do you have it on a branch that I could see? |
IIRC, I had problems with the Qt4 backend... |
Just want to add my +1 to strongly support a fully OO plotting interface. |
Turns out this is rather hard to implement without a significant backend redesign and/or refactor. See discussion in #1457. |
I would like to start using the matplotlib OO interface more, as I would prefer to use this when interactive plotting is not needed. It it slightly faster, and behaves more intuitively in terms of reference counting (pyplot keeps a reference to each figure, meaning that if figures are not closed by pyplot, memory goes out of control).
The reason I don't use it is because it's not easy to remember all the set-up of the canvas and figure:
So I was wondering whether it would be possible to make
Figure
more intelligent in terms of canvas? The 'ideal' API in my mind would be:i.e. I want the figure to just use the default backend (since this is set at the root level of matplotlib, not pyplot). So I would expect the following to work:
and to use the non-interactive Agg backend.
Is this something that has been considered before?
The text was updated successfully, but these errors were encountered: