You cannot put figure in figure .
You must modify your build functions to accept axes objects as an argument.
I also donβt understand why kwarg figure exists, I think this is an artifact of how inheritance works, the way to automatically generate documentation and how some of the recipients / setters work is automated. If you notice, he says that figure documented in the figure documentation, so it may not do what you want;). If you dig a little, what kwarg really controls is the number in which the created axes are also created. This is not what you want.
In general, moving existing axes / artists between pieces is not easy, there are too many bits of internal plumbing that need to be reconnected. I think it can be done, but it will include touching the internal components, and there is no guarantee that it will work with future versions or that you will receive a warning if the internal changes change so that it breaks it.
You need your graphing functions to accept the axes object as an argument. You can use a template, for example:
def myPlotting(..., ax=None): if ax is None:
therefore, if you pass the axes object to which it is drawn (you need new functionality), but if you are not all, then your old code will work as expected.
source share