## Re: [Matplotlib-users] multiple lines

 Re: [Matplotlib-users] multiple lines From: Howard Sun - 2010-06-02 15:30:53 Thanks alot, Alan, Angus, Ben, Eric and Malte, for the tips and the varieties. Matplotlib is awesome! Howard Sun, Ph.D. NVIDIA CORP. 2701 San Tomas Expressway Santa Clara, CA 95050 T (408) 566-5036 F (408) 486-8207 -----Original Message----- From: Eric Firing [mailto:efiring@...] Sent: Tuesday, June 01, 2010 7:07 PM To: matplotlib-users@... Subject: Re: [Matplotlib-users] multiple lines On 06/01/2010 02:47 PM, Benjamin Root wrote: > Howard, > > Are you trying to plot 4 lines with the same y-axis or with two or more > y-axes? I only ask because the values of your 5th column are many > orders of magnitude smaller than the values of the other ys. > > If you want multiple y-axes on the same plot, then you might want to > look at Parasite Axes. If not, then you can very simply plot this like > so (assuming that 'data' is a 2-D numpy array). > > import matplotlib.pyplot as plt > > plt.plot(data[:, 0], data[:, 1]) > plt.plot(data[:, 0], data[:, 2]) > plt.plot(data[:, 0], data[:, 3]) > plt.plot(data[:, 0], data[:, 4]) > > plt.show() > > I am sure that my 4 plot statements can be simplified, but I can't > verify that right now. import numpy as np import matplotlib.pyplot as plt x = np.arange(2, 5, 0.3) y = np.random.randn(len(x), 4) # dummy data for illustration plt.plot(x, y) So with the data array as above, it would be plt.plot(data[:,0], data[:, 1:]) Eric > > I hope that helps. > > Ben Root ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users ----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -----------------------------------------------------------------------------------