|
From: Russell E. O. <ro...@uw...> - 2010-12-21 20:39:03
|
In article <4D0...@gm...>,
Jose Guzman <sjm...@go...>
wrote:
> Hi everybody
>
> I wanted to collect a combination of plots to insert then in a subplot.
> I choose to create Line2D objects to use the .add_line() method of the
> AxesSubplot class, but unfortunately this does lead to the desired results.
>...
Is the appended closer to what you had in mind?
-- Russell
from matplotlib.lines import Line2D
from matplotlib.pyplot import figure, show
import numpy as np
def subplot_foo(n):
""" returns a the combination of 2 Line2D instances """
x = np.arange(0, 200, 0.1)
y = np.random.randn(len(x))
print len(x)
y2 = y+n
line1 = Line2D(x, y, color = 'k')
line2 = Line2D(x, y2, color = 'r')
return line1, line2
fig = figure() # create Figure object
for i in range(1,5):
ax = fig.add_subplot(2,2,i)
subplots = subplot_foo(i)
for subplot in subplots:
ax.add_line(subplot)
show()
|