Re: [Matplotlib-users] plot different columns
Fabian Braennstroem <[EMAIL PROTECTED]> writes: > Lets say I have to columns, the I could use in a script: > > res=plot(array_mapped[:,0],array_mapped[:,1], 'b', > array_mapped[:,0],array_mapped[:,2], 'g') > > The next time a have 5 columns in a file and want to plot all 5 > columns without adjusting the 'plot' command in the script, but just > by defining an argument when starting the script. Perhaps 'plot' is not the ideal interface for your purposes. How about something like this: #!/usr/bin/env python import matplotlib from matplotlib.lines import Line2D import pylab import numpy as npy def myplot(ax, matrix, linestyle, color): for column in range(1, matrix.shape[1]): line = Line2D(matrix[:,0], matrix[:,column], linestyle=linestyle, color=color) ax.add_line(line) colors = 'brk' for d in range(2,5): fig=pylab.figure() ax=fig.add_subplot(111) matrix = npy.random.rand(d,d) matrix[:,0] = npy.linspace(0, 1, num=d) myplot(ax, matrix, '-', colors[d-2]) pylab.show() -- Jouni K. Seppänen http://www.iki.fi/jks - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plot different columns
Hi, Alan G Isaac schrieb am 09/13/2007 06:15 PM: > On Thu, 13 Sep 2007, Fabian Braennstroem apparently wrote: >> Does nobody have an idea; especially for the 'dynamic' >> number of plotted arrays!? > > The question is unclear. > The problem seems easy enough, > if you get your hands on the arguments to your script. > http://homepage.mac.com/andykopra/pdm/tutorials/simplifying_script_arguments.html Thanks for your help; the question is a bit unclear indeed... Handling the sys.argv was not the problem; actually my main problem is to tell the 'plot' or 'loglog' command, that I have a different number of arrays. Lets say I have to columns, the I could use in a script: res=plot(array_mapped[:,0],array_mapped[:,1], 'b', array_mapped[:,0],array_mapped[:,2], 'g') The next time a have 5 columns in a file and want to plot all 5 columns without adjusting the 'plot' command in the script, but just by defining an argument when starting the script. I have to adjust somehow dynamically the plot command to adjust the number of graphs in one figure; but that is the problem... Fabian - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users