How to display a stacked barchart in Gnuplot?

穿精又带淫゛_ 提交于 2019-11-29 02:49:57

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/12235683/how-to-display-a-stacked-barchart-in-gnuplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!