I want to have two different gradients. Is this possible with two different palettes? And yes, how to declare them?
Asked
Active
Viewed 3,363 times
1
-
2It depends ;) See [Gnuplot, pm3d and surfaces](http://stackoverflow.com/q/18243527/2604213) for a possiblity to have two functions with different palettes. The drawback is, that you don't have two colorboxes. But you could create them manually... Another way would be to superimpose two images with `multiplot`, which has other drawbacks. So it really depends on your use case. If you could be more explicit about your application, we could help you better. – Christoph Jan 17 '14 at 22:16
-
It is hard to explain more explicit because my very poor Englisch. But your example is for me a new way of thinking, thanks for that. – Con Jan 18 '14 at 13:58
-
Ok, I thought that you maybe have some examplary image. The main point is about the colorboxes: do you need to show both color boxes? If the answer I linked is a good starting point, then you may expand the question later if you encounter some problems with this. – Christoph Jan 18 '14 at 15:14
-
First of all i have perfect vertical gradient made, look to the last examples on my site [link](http://ccvd.eu/Energie.html). In this case i had a datafile allways with positive and negative values. – Con Jan 18 '14 at 22:07
-
First of all i have perfect vertical gradient made, look to the last examples on my site [link](http://ccvd.eu/Energie.html). In this case i had a datafile allways with positive and negative values. But now i have data with 3 situations, 1; only negative, 3; only positive and 3 both values. And this is the results with only negative values. Look to my example: [link](http://ccvd.eu/downloads/verkeerdegradient.png). The script i use to make the gradient: set palette defined (-1 "#D30000", 0 "#00F000", 0 "#FFF900", 1 "#FF0700"), allmost the same as the examples on my site. – Con Jan 18 '14 at 22:16
-
First of all i have perfect vertical gradient made, look to the last 7 examples on my site [link](http://ccvd.eu/Energie.html). In this case i had a datafile allways with positive and negative values. But now i have data with 3 situations, 1; only negative, 2; only positive and 3 both values. And this is the results with only negative values. Look to my example: [link](http://ccvd.eu/downloads/verkeerdegradient.png). The script i use to make the gradient: set palette defined (-1 "#D30000", 0 "#00F000", 0 "#FFF900", 1 "#FF0700"), allmost the same as the examples on my site. – Con Jan 18 '14 at 22:17
1 Answers
0
I guess the problem is that you don't set a fixed cbrange
. The numerical values given in the set paletted defined
statement are relative values. According to your previous questions you scale the color to the range [-1:1]
. In that case, your relative values in the palette definition and those in the plots coincide. However, if you have only positive or only negative values, then you have effectively a cbrange
of [-1:0]
or [0:1]
. Just use a set cbrange [-1:1]
and it should work.
The following minimal example shows your first what happens without setting a cbrange, and then in the second plot the result with a fixed cbrange
:
The file test.txt
contains the values
1 5
2 3
3 2
The gnuplot script is:
set boxwidth 0.8 relative
set palette defined (-1 "#D30000", 0 "#00F000", 0 "#FFF900", 1 "#FF0700")
set style data boxes
set style fill solid 1.0 noborder
unset key
unset colorbox
set multiplot layout 1,2
set title 'wrong colors'
plot for [i=51:1:-1] 'test.txt' using 1:($2*i/51.0):(i/51.0) lc palette
set title 'correct colors'
set cbrange[-1:1]
replot
unset multiplot
The result with 4.6.3:

Christoph
- 47,569
- 8
- 87
- 187