0

There seems to be no way to define two different palettes (set palette 1 ...) in gnuplot (5.0). With three datasets in stdin I can plot them using three different colors or even one with palette and the other two with colors. But how to plot first two with different palettes ?

Tried replot but it is confusing and didn't help

set xrange [0:10]
set yrange [0:10]
set cbrange [0:50]
set palette rgbformulae 10,13,3

plot '-' w l lc palette, '-' w l lc rgb 'green', '-' w l lc rgb 'blue'; 
1 2 10 
2 2 20 
3 2 30
4 2 40
5 2 50
e
1 4 10 
2 4 20 
3 4 30
4 4 40
5 4 50
e
1 1
2 2 
3 3 
4 4 
5 5

I expect an approach that would let me plot two datasets with two different paletts and third dataset with a given color

Andor
  • 11
  • 2
  • just recently, there was a similar question with `splot` and different palettes (https://stackoverflow.com/q/57465513/7295599). Maybe the answer there also helps in your case?! – theozh Aug 29 '19 at 12:36

2 Answers2

0

I've found two solutions. The first is to just split palette, say into positive an negative values and use them separately for the first two lines :

set palette defined (\
        -50 '#00aa00', -25 '#aaee00', 0 '#eeff00',\
        0 '#ffee00' , 25 '#cccc00', 50 '#ff0000') 

plot \
'-' u 1:2:($3) w l lw 5 lc palette,\
'-' u 1:2:(-$3) w l lw 5 lc palette,\
'-' w l lc rgb 'blue'; 

Second solution is, as @theoz pointed out, to use color functions for line colors:

r1(x) =int(255*sin(0.5*pi*x/50)) << 16
g1(x) = 0 
b1(x) = 0 

r2(x) = 0 
g2(x) = int(255*sin(0.5*pi*x/50)) << 8 
b2(x) = 0 

p1(x) = r1(x)+g1(x)+b1(x)  
p2(x) = r2(x)+g2(x)+b2(x) 

plot '-' u 1:2:(p1($3)) w l lw 4 lc rgb var,\
'-' u 1:2:(p2($3)) w l lw 4 lc rgb var,\
'-' w l lw 4 lc rgb 'blue'
Andor
  • 11
  • 2
0

It seems v6 now allows creation of named palettes, and use of several palettes in the same plot :) See the Gnuplot v6 Named Palette demo

armando.sano
  • 345
  • 1
  • 3
  • 9