开发者

How to display a stacked barchart in Gnuplot?

I have a data file that looks a bit like this:

A 0.2  0.5
B 0.65 0.8
C 0.4  0.2

i.e., it contains three columns where the first column contains labels and the other two columns float values. Columns are separated by spaces.

I'd like to plot this in a way that the labels appear as tics on the x-axis while the columns are plotted as two differently colored barcharts on top of each other.

How can I achieve this开发者_开发问答 using Gnuplot?


Assuming your data are stored in the file 1.dat, stacked barcharts might be generated as follows:

set style data histograms
set style histogram rowstacked
set boxwidth 1 relative
set style fill solid 1.0 border -1
set yrange [0:1.5]
set datafile separator " "
plot '1.dat' using 2 t "Var 1", '' using 3:xticlabels(1) t "Var 2"

As you can see, barcharts are no different from histograms (at least, from within Gnuplot). More information can be found on gnuplot demo page.

How to display a stacked barchart in Gnuplot?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜