python gnuplot read from file

前端 未结 1 1972
旧巷少年郎
旧巷少年郎 2021-01-24 19:13

i have a file with the following data the first field is UNIXTimestamp,

1351734672.095 25
1351734674.449 52
1351734676.638 612
1351734680.669 44
1351734681.121 16         


        
1条回答
  •  不思量自难忘°
    2021-01-24 19:34

    Using Gnuplot.File instead of Gnuplot.Data, it is possible to get the following plot:

    output.png

    #!/usr/bin/env python
    
    #from numpy import *
    import Gnuplot
    
    g = Gnuplot.Gnuplot()
    g.title('My Systems Plot')
    g.xlabel('Date')
    g.ylabel('Value')
    g('set term png')
    g('set out "output.png"')
    #proc = open("response","r")
    #databuff = Gnuplot.Data(proc.read(), title="test")
    
    databuff = Gnuplot.File("response", using='1:2',with_='line', title="test")
    g.plot(databuff)
    


    UPDATE:

    For the overlap, you can change 45 to -45 :

    #g('set xtic rotate by 45 scale 1 font ",2"')
    g('set xtic rotate by -45 scale 1 font ",2"')
    

    enter image description here

    0 讨论(0)
提交回复
热议问题