2

I want to use python Gnuplot to plot a bar graph; however, I didn't find the specific manual or instruction to do that, and thanks for any suggestions.

I was doing:

graph = Gnuplot.Gnuplot(debug=1)
graph.plot(Gnuplot.Data(exp_data[0],exp_data[1],title='exp')
Hailiang Zhang
  • 17,604
  • 23
  • 71
  • 117

1 Answers1

3

The trick with Gnuplot is that you can use the same instructions you use on the gnuplot shell. So you only need to check a gnuplot demo for bar charts to know how to do things:

>>> from Gnuplot import Gnuplot
>>> gp = Gnuplot()
>>> gp('set style data histograms')
>>> gp('set style fill solid 1.0 border -1')
>>> gp.plot([8,2,6,4,5])

enter image description here

Although in gnuplot-py you have methods to set plot parameters, this text approach allows you to reach the full power of gnuplot and in cases when you only have documentation for gnuplot (that is good and extense, btw) it is a straightforward way of getting things done.

As others commented, the general advice is to have a look at matplotlib. Not long ago, I often prefered gnuplot to plot 3D graphics because its speed. However matplotlib plot3d is currently behaving very well for that purpose.

joaquin
  • 82,968
  • 29
  • 138
  • 152