How to display a stacked barchart in Gnuplot?

后端 未结 1 1067
Happy的楠姐
Happy的楠姐 2020-12-29 10:04

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 cont

1条回答
  •  误落风尘
    2020-12-29 10:24

    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.

    enter image description here

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