I'm trying to draw the axes from one figure directly over the axes for another figure, in a sense, combining the two axes as two layers on one figure.
So, first I get an axes instance, "ax".
import matplotlib.pyplot as plt
plt.plot(range(10), [i^2 for i in range(10)])
Okay, now I have the axes "ax". I want to draw ax directly on top of the following figure, and get a result that would be the same as if I had called the plot command above directly in the following code. All I'm passed in my real code is the newax variable below, which is why I use newax.get_figure()).
However, the result of test2.png is not very pretty and definitely not what I want. The tick labels for the y-axis are all scrunched up, for example.
Can anyone help?
For those curious, what I'm doing is working on getting the Sage graphics code to be able to wrap and intelligently display matplotlib axes objects, so that a person could easily create a matplotlib axes, wrap it in the Sage graphics class, and then be able to manipulate it in Sage. In order for this to work, it seems like I need to save the axes object I care about, and then when Sage composes it's final figure (using matplotlib), it passes me an AxesSubplot object. I need to somehow take that subplot object and draw my saved axes on it in the most intelligent way possible. In the code above, I try taking the given AxesSubplot object, getting the figure from that, and then just adding my saved axes to that figure. Is there a better way to do this?