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

1
  • just recently, there was a similar question with splot and different palettes (stackoverflow.com/q/57465513/7295599). Maybe the answer there also helps in your case?! Commented Aug 29, 2019 at 12:36

2 Answers 2

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'
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.