|
From: Eric F. <ef...@ha...> - 2012-10-03 16:55:51
|
On 2012/10/03 4:24 AM, Charleux Ludovic wrote:
> Hello,
>
> I want to plot multiple lines using matplotlib.pyplot.plot using the
> None separator: when i zoom or plot lines that go far away from the axis
> limits, they their direction is changed. I encounter a bug shown by the
> folowing code:
>
> import matplotlib.pyplot as plt
>
> # Single line
> x = [0., 1., 1., 0., 0.]
> y = [0., 0., 1., 1., 0.]
>
> # Multiple lines separated by None
> x2 = [0., 1., None ,1., 0.]
> y2 = [0., 0., None, 1., 1.]
I'm surprised this works at all. I don't think we have ever
intentionally supported object arrays, which is what you get when you
take np.array() of a list with a None in it.
If you want to use this method to make a set of line segments, use
np.nan in place of None.
Eric
>
> # Let's plot
> fig = plt.figure(0)
> plt.clf()
> ax = fig.add_subplot(121)
> plt.title('No zoom')
> plt.xlim([-1, 2])
> plt.ylim([-1, 2])
> plt.plot(x,y, 'bo-', label = 'This is ok')
> plt.plot(x2,y2, 'ro-', label = 'This is not ok')
> plt.legend()
> ax = fig.add_subplot(122)
> plt.title('With zoom one a corner')
> plt.xlim([-.05, .1])
> plt.ylim([.95, 1.05])
> plt.plot(x,y, 'bo-', label = 'This is ok')
> plt.plot(x2,y2, 'ro-', label = 'This is not ok')
> plt.legend()
> plt.show()
>
> I tried several approaches to solve the problem but never succeeded. I
> don't wich to use 2D arrays or LineCollections because this solution is
> faster and allows the declaration of all lines with a single label and
> color. Has anyone any idea ?
>
> Regards.
>
>
>
>
> ------------------------------------------------------------------------------
> Don't let slow site performance ruin your business. Deploy New Relic APM
> Deploy New Relic app performance management and know exactly
> what is happening inside your Ruby, Python, PHP, Java, and .NET app
> Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> http://p.sf.net/sfu/newrelic-dev2dev
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
|