Andrey Sapegin
Andrey Sapegin

Reputation: 484

How to define fill colour for columnstacked histogram in gnuplot

how can I change the fill colour for columnstacked histogram? My data looks like:

xticlabel_1 xticlabel_2 xticlabel_3
10 20 15

and my script:

set datafile separator "\t"
set term postscript colour solid
set size 1,0.5
set output 'duplication_stats.eps'
set style data histograms
set style histogram columnstacked
set boxwidth 0.5
set style fill solid border -1
set tics scale 0.0
set ytics
set xtics rotate by -20
#
plot 'duplication_stats' using 2 ti col lc rgb "grey"
  1. If I remove "columnstacked", then xtic labels disappear, but the plotted histogram bar is grey, as expected.

  2. If "columnstacked" is used, then the histogram bar is red, and 'lc rgb grey' is simply ignored.

And I want to have both - (1) xtic labels from first row and (2) different colours for histogram bars plotted from different columns.

Do you know how to achieve it?

Thank you very much in advance.

Upvotes: 2

Views: 4362

Answers (1)

Christoph
Christoph

Reputation: 48390

For columnstacked histograms all entries of one row are plotted with the same color, the next row would use another color. Principally you can achieve what you want using newhistogram to set another color each time and also do manual positioning with at <xpos> after the newhistogram.

set term postscript colour solid
set size 1,0.5
set output 'duplication_stats.eps'
set style data histograms
set style histogram columnstacked
set boxwidth 0.5
set style fill solid 1.00 noborder
set tics scale 0.0
set ytics
set xtics rotate by -20
#
plot 'duplication_stats' u 1 lt 1 title columnhead,\
     newhistogram lt 2 at 1, '' u 2 ti col,\
     newhistogram lt 3 at 2, '' u 3 ti col

This gives me:

enter image description here

Note, that this works only since gnuplot 4.6 patchlevel 1, with 4.6.0 it doesn't work.

Upvotes: 3

Related Questions