From: Michael H. <hag...@jp...> - 2002-09-27 12:25:58
|
chuck clark writes: > I think my problem lies in the fact of I'm not sure which PlotItem > type from gnuplot-py I should use. I was originally trying to use > Data but of course "12:01" can't be converted to a Numeric Float > array. So now I'm taking a step back and wondering if I need to > create my own PlotItem types of Date, Time and DateTime to do this? > [...] > gnuplot> set xdata time > gnuplot> set timefmt "%H:%M" > gnuplot> set format x "%H:%M" > gnuplot> set xrange ["12:00":"12:05"] > gnuplot> plot "/home/cclark/test.dat" using 1:2 A PlotItem object represents a whole plot including all of the associated data (if any), and the plot sub-command that has to be sent to gnuplot (e.g., '"/tmp/sxhhfy" using 1:3 with linespoints'). You can use any of the data-based PlotItems defined in the CVS version (_InlineFileItem, _FIFOFileItem, or _TempFileItem); you just have to call its constructor using the content that needs to be sent to gnuplot as one of the arguments. For example, this should work (untested): >>> content = """\ ... 12:01 4.63 ... 12:02 6.74 ... 12:03 0.0 ... 12:04 6.32 ... """ >>> plot_item = PlotItems._TempFileItem(content, with='linespoints') >>> g = Gnuplot.Gnuplot() >>> g('set xdata time') >>> g('set xdata time') >>> g('set timefmt "%H:%M"') >>> g('set format x "%H:%M"') >>> g('set xrange ["12:00":"12:05"]') >>> g.plot(plot_item) >>> The only trick is getting your data into a "content" string that gnuplot can understand. You can do that any way you want. PlotItems.Data() is now a helper function that does mainly that; you can use it as a starting point. I haven't decided whether to make the _InlineFileItem etc classes a part of the Gnuplot.py published interface, which is why their names start with '_'. I might rename them before the next Gnuplot.py release. Michael -- Michael Haggerty hag...@jp... |