From: kevin p. <ke...@ma...> - 2004-11-06 04:44:42
|
Michael Haggery, Thanks for taking the time to respond. This is a very elegant and instructive. I like the way that you set the styles in the styles dictionary. I would not have thought to do that. I wasn't aware that the data for Gnuplot.py, could also go into a separate file. That certainly makes for less cluttered code. I have be playing and tweeking the code you sent and tried 'steps' and linesplots and changing the grid. Everything works, but i wonder if there is not some more elegant way to represent this data. I am wondering if there is a way to not only use plot, but splot? Having x be the time (column 1), y be the value from column 2 and have z be the last value (column 4) and then having the linespoints being not only a different style but spread out on the z axis to boot. Perhaps that would be more salient? Problem is, when i try to change: items = [ Gnuplot.Data( subsets[value], with=styles[value], using=(1,3,), ) for value in values ] g.plot(*items) to use splot the whole thing barfs..... and i can't quite get my head around the splot entry in the manual. I wonder if you could suggest an splot approach that is more visually clear. It seems that splot is quite a different beast. In any case thanks for you instructions thus far. That is helpful handiwork in that script, a real pea-shooter! cheers, kevin On Nov 5, 2004, at 9:31 PM, Michael Haggerty wrote: > kevin parks wrote: > >> I have data that looks like: >> >> 0 5.5 0 1 >> 2 5.5 2 4 >> 4 5.5 4 2 >> 6 5.5 5 3 >> 8 5.5 7 1 >> 10 5.5 9 4 >> 12 5.5 11 3 >> 14 5.5 0 2 >> 16 5.5 2 1 >> 18 5.5 4 4 >> 20 5.5 5 3 > > > It's easiest if you put your data into a file in the above format, > rather than typing it into Python as a list constant. > >> [...] I would like to use splot and points of different colors to >> convey as much info as i can. The X axis would be the time axis (that >> would take care of the first two parameters) and the Y axis could be >> the third column. Then for the fouth item, there are only four >> possibilities (1, 2, 3, or 4), so i thought that i could use points >> of red, blue, green, black to indicate that. > > > I don't believe gnuplot offers a way to vary the style of points > depending on a data column, so I believe you should read the data into > Python, then use Python to pick it apart into four separate data sets, > then plot the four sets in one plot using four different data styles. > I believe the following script should do the trick. It uses some > newer python features (2.2?) so parts might have to be changed if you > are using an older version of python. Run it with the name of your > data file as command-line argument. > > |#! /usr/bin/env python > > import sys > import Numeric > import Gnuplot > > [filename] = sys.argv[1:] > > data = [] > > for l in open(filename).readlines(): > l = l.strip().split() > data.append([float(l[0]), float(l[1]), float(l[2]), int(l[3])]) > > values = [1,2,3,4] > > # Here you can adjust the style options for each subset. The > # interpretation of the numbers depends on what "terminal" you are > # using. > styles = { > 1 : 'points pt 1', > 2 : 'points pt 2', > 3 : 'points pt 3', > 4 : 'points pt 4', > } > > subsets = {} > for value in values: > subsets[value] = [l for l in data if l[3] == value] > > g = Gnuplot.Gnuplot() > items = [ > Gnuplot.Data( > subsets[value], > with=styles[value], > using=(1,3,), > ) > for value in values > ] > > g.plot(*items) > > raw_input('Press enter to continue') > > > Yours, > Michael > | > > -- > Michael Haggerty > mh...@al... > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Sybase ASE Linux Express Edition - download now for FREE > LinuxWorld Reader's Choice Award Winner for best database on Linux. > http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > _______________________________________________ > Gnuplot-py-users mailing list > Gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-py-users |