So if you pass in an Axes object it gets drawn to (the new functionality you need), but if you don't all of your old code will work as expected. Importing import matplotlib.pyplot as plt. Merits of Matplotlib Generally easy to get started for simple plots. You can use a pattern like: def myPlotting(., ax=None): I've only learned a little bit, but can create various graphs through Matplotlib, which is an 2D and 3D graphics library for generating scientific figures. You need to your plotting functions to take an Axes object as argument. I think it can be done, but will involving touching the internals and there is no guarantee that it will work with future versions or that you will get warning if the internals change in a way that will break it. In general, moving existing axes/artists between figures is not easy, there are too many bits of internal plumbing that need to be re-connected. If you dig down a bit, what that kwarg really controls is the figure that the created axes is attached too, which is not what you want. If you note, it says figure is undocumented in the Figure documentation, so it might not do what you want ). I am also unclear why the kwarg figure is there, I think it is an artifact of the way that inheritance works, the way that the documentation is auto-generated, and the way some of the getter/setter work is automated. You should modify your plotting functions to take axes objects as an argument. I've done quite a bit of googling around, and experimented extensively, but it's clear that I've missed something that is either really subtle, or embarrassingly obvious (I'll be happy for it to be the latter as long as I can get un-stuck). What I get for the final line in the above code block-fig1.show()-isĪ collection of four empty plots that have frames and x- and y- tickmarks/labels. I know for a fact the individual plots returned from the function invocations are viable-I did a figa.show().,figd.show() to confirm that they are OK. In short, here's stripped-down pseudocode for what I've tried: fig1 = plt.figure(1, facecolor='white') How can I use a matplotlib Figure object as a subplot? Specifically, I have a function that creates a matplotlib Figure object, and I would like to include this as a subplot in another Figure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |