On 10/07/2011 02:45 PM, Charles Gagnon wrote:
> I had a gnoplot script I am trying to convert into python using
> gnuplot-py. I have a list of historical prices like this:
>
> 2010-11-24,19.33,19.55,19.32,19.46,63880400,19.2
>
> My basic gnuplot call were:
>
> set grid nopolar
> set grid xtics nomxtics ytics nomytics noztics nomztics nox2tics
> nomx2tics noy2tics nomy2tics nocbtics nomcbtics
> set grid layerdefault linetype 0 linewidth 1.000, linetype 0 linewidth 1.000
>
> # Chart Title
> set title "CSCO 1yr"
>
> set xdata time
> set timefmt "%Y-%m-%d"
> set format x "%m/%y"
>
> set lmargin 9
> set rmargin 2
> set datafile separator ","
>
> plot 'data/CSCO_365.csv' using 1:2:3:4:5 notitle with financebars lt 8
>
> Instead of doing it through a csv, I was trying to plot from the list
> directly. So I took out the datafile seperator but I am having a hard
> time porting that to python. Most of my options were just set with a
>
> g('set lmargin 9')
>
> line. But I'm not sure how to handle my plot statement. I can pass my
> list to g.plot() but it lacks all the other definitions. What am I
> missing?
Gnuplot.py only has support for plotting numbers, not dates. You would
probably have to either derive your own PlotItem class or teach the
existing PlotItem classes how to work with dates.
One alternative that might work: if gnuplot can parse some numerical
format as dates (e.g., unix timestamp long values), then maybe you could
convert the dates to numbers then pass them to gnuplot as numbers.
However, you might lose too much precision, as Gnuplot.py would probably
want to convert the numbers to doubles or floats.
Michael
--
Michael Haggerty
mh...@al...
http://softwareswirl.blogspot.com/
|