Gnuplot, can you use two different palettes worship?

安稳与你 提交于 2019-12-12 04:43:04

问题


I want to have two different gradients. Is this possible with two different palettes? And yes, how to declare them?


回答1:


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:



来源:https://stackoverflow.com/questions/21196047/gnuplot-can-you-use-two-different-palettes-worship

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!