Victor Kalmaev
Victor Kalmaev

Reputation: 65

Gnuplot: color for stacked histogram bars

I want to create this histogram with gnuplot: sample

I used the 6th example from http://gnuplot.sourceforge.net/demo/histograms.html

datafile has the next structure:

Region Austria Hungary ...

1891-1900 234081 181288 ...

1901-1910 668209 808511 ...

...

https://github.com/gnuplot/gnuplot/blob/master/demo/immigration.dat

The minimal script I've got here http://gnuplot.sourceforge.net/demo/histograms.6.gnu

Is it possible to set the custom color for periods?

Upvotes: 2

Views: 1495

Answers (1)

ewcz
ewcz

Reputation: 13087

Perhaps not the most elegant solution, nevertheless one could prescribe the colors manually by overriding the default linetypes:

set lt 1 lc rgb 'red'
set lt 2 lc rgb 'orange-red'
set lt 3 lc rgb 'orange'
set lt 4 lc rgb 'yellow'
set lt 5 lc rgb 'green'
set lt 6 lc rgb 'blue'
set lt 7 lc rgb 'dark-blue'
set lt 8 lc rgb 'violet'

plot 'immigration.dat' using 6 ti col, '' using 12 ti col, '' using 13 ti col, '' using 14:key(1) ti col

In combination with your minimal script, this produces: enter image description here

Upvotes: 3

Related Questions