|
From: <e....@nk...> - 2012-02-20 16:40:06
|
As far as I can tell, this line is wrong
g.plot(data using 2:xtic(1) title "Oct-09 data growth(gb)", ''
using 3 title "Nov-09 data growth(gb)", '' using 4 title "Dec-09 data
growth(gb)")
you must create the data like this
data = [ Gnuplot.Data(x0 , y0 , title="Nov-09 etc") ,
Gnuplot.Data(x1 , y1 , title="Dec-09 etc") ,
]
where x0,y0 (etc) are the data arrays, then plot it with
g.plot(*data)
Edo
> -----Original Message-----
> From: Roberto Rodríguez-Rodríguez [mailto:ro...@gm...]
> Sent: Monday, February 20, 2012 5:20 PM
> To: gnu...@li...
> Subject: [Gnuplot-py-users] Problem working with xtics
>
> Hi, I need to do a bar graph with categories, I found these example
>
> http://www.ibm.com/developerworks/aix/library/au-gnuplot/index.html
>
> I need to do something similar, for many data. I tried to
> replicate the example on python. I wrote the respective code
> I append it at the end of the message.
>
> but I got these error:
> File "./graph.py", line 119
> g.plot(data using 2:xtic(1) title "Oct-09 data growth(gb)", ''
> using 3 title "Nov-09 data growth(gb)", '' using 4 title "Dec-09 data
> growth(gb)")
> ^
> SyntaxError: invalid syntax
>
> The function fileopen2 is just for parsing the file with the
> data, I got a matrix wich I tried to graph. The problem is
> with the plot command, I don't know how to manage categories
> with gnuplot.py, I have looking in the web in several places
> but all the examples don't touch these part.
>
> these is my code
>
> #! /usr/bin/env python
>
> import Gnuplot, Gnuplot.funcutils, sys
> import sys
> import re
> import math
>
> #*************************************************************
> ******************
> def plot2D(data):
> print sys.maxint
> g = Gnuplot.Gnuplot() #persist=1)
> g.title('Memory writes')
> g('set terminal png truecolor')
> g('set grid')
> g('set style data histograms') # give gnuplot an
> arbitrary command
> g('set style fill solid 1.00 border -1')
> g('set xlabel "page_number"')
> g('set ylabel "number of writes"')
> g('set autoscale')
> g.plot(data using 2:xtic(1) title "Oct-09 data growth(gb)", ''
> using 3 title "Nov-09 data growth(gb)", '' using 4 title "Dec-09 data
> growth(gb)")
> g.hardcopy("blah.png",terminal="png")
> raw_input('Press enter to continue...\n')
> #*************************************************************
> ******************
>
> #*************************************************************
> ******************
> def file_open2(DataFile):
> #Open the file
> # print "open"
> try:
> data_file = open(DataFile, "r") #open the file
> data_points=data_file.read() #save the file in a list
> line_points=data_points.split('\n') #split
> the file by new lines
> data_file.close()
> except IOError, e:
> print >> sys.stderr, "File Open Error:", e
> sys.exit(2)
>
> reg_exp=re.compile(r"\s+") #reg_exp for separate each
> token in the list
> mem=[[]]
> print "Putting data in an array"
> for i in range(len(line_points)-1):
> mem_line=reg_exp.split(line_points[i])
> for j in range(len(mem_line)):
> if j==0:
> mem[i].append((mem_line[j]))
> else:
> mem[i].append(float(mem_line[j]))
> mem.append([])
> mem.pop()
> return mem
> #*************************************************************
> ******************
>
> if __name__ == '__main__':
> plot2D(file_open2(sys.argv[1]))
>
>
> the file that have the data contains:
>
> hdisk2 420 425 410
> hdisk3 700 780 760
> hdisk4 450 450 452
> hdisk5 680 702 690
> hdisk6 320 330 329
> hdisk7 530 515 514
>
> I really appreciate any help. Thank you
>
> --
> Best Regards
> Roberto
>
> --------------------------------------------------------------
> ----------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft
> developers is just $99.99! Visual Studio, SharePoint, SQL -
> plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future
> releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> Gnuplot-py-users mailing list
> Gnu...@li...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-py-users
>
|