Skip to content
Advertisement

How to plot using a prewritten library function into a subplot?

I’ve been stumbling around this issue for a while, but today I really want to figure out if it can be done.

Say you have a function from a library that does some plotting, such as:

JavaScript

If I want to add this single plot multiple times to my own subplots, how could I do this?

I’m not able to change the plotting_function, as it’s from a library, so what I’ve tried is:

JavaScript

This results in an empty subplot with the line graphs plotting separate.

Is there any simple answer to this problem? Thanks in advance.

Advertisement

Answer

I think you might be better off to monkey patch plt.subplots(), but it is possible to move a subplot from one figure to another. Here’s an example, based on this post:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement