On Monday, December 20, 2010, 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.
>
> Here my dummy version:
>
> 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, 'r')
>
> #return line1+line2
> return line1
>
>
> fig = figure() # create Figure object
> for i in range(1,5):
> ax = fig.add_subplot(2,2,i)
>
> ax.add_line(subplot_foo(i))
>
> show()
>
> First, the Line2D object does not represent
> the plot I want to create.
> Second, I cannot collect various Line2D objects into a Subplot.
>
> Any good idea around?
>
>
>
>
You might want to look at LineCollection objects.
Ben Root
|