Suppose I have two functions returning axes:
def f1():
f = plt.figure()
ax = f.add_axes(111)
ax.plot(....)
ax.lengend(....)
return ax
def f2():
similar to f1
now I have a figure
main_fig = plt.fig()
I want to merge axes from f1 and f2 in a unique axes (withou splitting
the figure). For example if f1 produces a line and f2 produces another
line I want to see two lines in the same plot at the end.
From: Ruggero [mailto:giurrero@…287…]
Sent: Thursday, October 21, 2010 17:59
I want to merge axes from f1 and f2 in a unique axes (withou splitting
the figure). For example if f1 produces a line and f2 produces another
line I want to see two lines in the same plot at the end.
If you can modify the functions slightly, perhaps having an optional axes
parameter would accomplish what you want:
def f1(axes=None):
if axes is None:
axes = plt.figure().add_subplot(1, 1, 1)
# Now plot into the axes
# Likewise for f2
# Plot separately
f1()
f2()
# Plot together
axes = plt.figure().add_subplot(1, 1, 1)
f1(axes=axes)
f2(axes=axes)