Re: [Matplotlib-users] plot different columns
Hi Jouni, Jouni K. Seppänen schrieb am 09/20/2007 06:50 PM: > Fabian Braennstroem <[EMAIL PROTECTED]> writes: > >> Jouni K. Seppänen schrieb am 09/16/2007 05:51 PM: >>> def myplot(ax, matrix, linestyle, color): >[...] >> Thanks for your help! add_line seems to be the right >> function... I am not sure yet, if I need your function call, >> but I will check it!? > > Oh, I just wrote my suggestion as a "myplot" function called by a main > program as an example of what you could use instead of the built-in > "plot". There are of course many possible ways to organize your program. Thanks for your help; I was just a bit confused. I got it now. 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
Re: [Matplotlib-users] plot different columns
Fabian Braennstroem <[EMAIL PROTECTED]> writes: > Jouni K. Seppänen schrieb am 09/16/2007 05:51 PM: >> def myplot(ax, matrix, linestyle, color): [...] > Thanks for your help! add_line seems to be the right > function... I am not sure yet, if I need your function call, > but I will check it!? Oh, I just wrote my suggestion as a "myplot" function called by a main program as an example of what you could use instead of the built-in "plot". There are of course many possible ways to organize your program. -- 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 Jouni, Jouni K. Seppänen schrieb am 09/16/2007 05:51 PM: > 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() Thanks for your help! add_line seems to be the right function... I am not sure yet, if I need your function call, but I will check it!? 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
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
Re: [Matplotlib-users] plot different columns
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 hth, Alan Isaac - 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
Does nobody have an idea; especially for the 'dynamic' number of plotted arrays!? Regards! Fabian Fabian Braennstroem schrieb am 09/09/2007 09:01 PM: > Hi, > > I have a small script which reads a csv file with several > columns and puts it into an scipay array, which > I can plot using matplotlib. It works fine, but just with > explicitly setting the number of columns: > > res=loglog(array_mapped[:,0],array_mapped[:,1], 'b', > array_mapped[:,0],array_mapped[:,2], 'g', > array_mapped[:,0],array_mapped[:,3], 'r', > array_mapped[:,0],array_mapped[:,4], 'y', > array_mapped[:,0],array_mapped[:,5], 'k', > array_mapped[:,0],array_mapped[:,6], '-bo', > linewidth = 2) > > Is there a way to define the number of columns, which I want > to plot? Or even better, can I apply an sys.argv to > define the plotted columns, e.g. > "python csvplot.py all": which plots all columns with its > value for the y-coordinate and the line-number as x-coordinate > "python csvplot.py all1": which does the same as above, but > using column 1 as abscissae > "python csvplot.py 1 2 5": which plots columns 2 and 5 > against column 1... > > Would be nice, if anybody has an idea, how to achieve this!? > Regards! > 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/ - 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
[Matplotlib-users] plot different columns
Hi, I have a small script which reads a csv file with several columns and puts it into an scipay array, which I can plot using matplotlib. It works fine, but just with explicitly setting the number of columns: res=loglog(array_mapped[:,0],array_mapped[:,1], 'b', array_mapped[:,0],array_mapped[:,2], 'g', array_mapped[:,0],array_mapped[:,3], 'r', array_mapped[:,0],array_mapped[:,4], 'y', array_mapped[:,0],array_mapped[:,5], 'k', array_mapped[:,0],array_mapped[:,6], '-bo', linewidth = 2) Is there a way to define the number of columns, which I want to plot? Or even better, can I apply an sys.argv to define the plotted columns, e.g. "python csvplot.py all": which plots all columns with its value for the y-coordinate and the line-number as x-coordinate "python csvplot.py all1": which does the same as above, but using column 1 as abscissae "python csvplot.py 1 2 5": which plots columns 2 and 5 against column 1... Would be nice, if anybody has an idea, how to achieve this!? Regards! 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