利用python生成曲线图像的脚本,参考自:http://www.lorenzogil.com/projects/pycha/

 

 
  
  1. import cairo 
  2. import pycha.bar 
  3. width,height=500,400 
  4. surface=cairo.ImageSurface(cairo.FORMAT_ARGB32,width,height) 
  5. dataSet=( 
  6. ('dateset1',((0,1),(1,3),(2,2.5))), 
  7. ('dateset2',((0,2),(1,4),(2,3))), 
  8. ('dateset3',((0,5),(1,1,),(2,0.5))), 
  9. options={ 
  10. 'legend':{'hide':False}, 
  11. 'background':{'color''#f0f0f0'}, 
  12. chart=pycha.bar.VerticalBarChart(surface,options) 
  13. chart.addDataset(dataSet) 
  14. chart.render() 
  15. surface.write_to_png('test.png'

效果图: