GNUPlot中颜色栏中的不规则百分位数抽动 [英] Irregular percentile tics in colorbar in GNUPlot

查看:101
本文介绍了GNUPlot中颜色栏中的不规则百分位数抽动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本文件,其中包含三列:纬度,经度和百分比.文本文件如下所示(链接此处) :

I have a text file which contains three columns: latitude, longitude and a percentage. The text file looks like this (link here):

25.00  -28.00    0.3
25.00  -27.00    0.7
25.00  -26.00    1.6
25.00  -25.00    4.3
25.00  -24.00   10.0
25.00  -23.00   18.2
25.00  -22.00   33.9
25.00  -21.00   49.1
...

我想将此倾向作为热点图绘制在世界地图上(可以从网站作者

I want to plot this pertentages as a heatmap on top of a world map (the file for the world map for GNUPlot can be downloaded from the website author here)

问题出在颜色栏上,我想按不规则区域(百分位数)对值进行分组.很难解释,如果我用GNUPlot得到的图像和另一个具有所需结果的绘图,我将附加图像:

The problem is with the colorbar, which I want to group the values by irregular regions (percentiles). As it is difficult to explain, I am attaching an image if what I get with GNUPlot and another plot with the desired result:

GNUPlot尝试:

GNUPlot try:

生成图的代码是:

set palette maxcolors 10
set palette defined (0 "#000090",1 "#000fff", 2 "#0090ff",3 "#0fffee",4 "#90ff70",5 "#ffee00",6 "#ff7000",7 "#ee0000",8 "#7f0000", 9 "#7f0050")
set cbtics (99.9 , 99.6, 99.0, 97.5, 95.0, 90.0, 75.0, 50.0, 20.0, 10.0);
plot [-30:40][25:70] "HeatMap_Test.txt" u 2:1:3 pt 5 ps 2 lc palette notitle, "world_10m.txt" with lines ls 1 notitle

所需结果:

除了GNUPlot中的颜色(它们不是最终的颜色)之外,您还可以看到,颜色条标记呈线性分布(使99.0以上的颜色全部粘在一起),并且未按颜色条标记所定义的区域分组

Besides from the colors in GNUPlot (which they are not the final ones), you can see that the colorbar tics distribute linearly (making the ones over 99.0 stick all toguether) and are not grouped by the regions defined by the colorbar tics.

是否可以在GNUPlot中进行此绘制?

Is there a way to do this plot in GNUPlot?

问题的第二部分在此处

推荐答案

您可以定义一个步骤函数,根据需要映射z列.

You can define a step function which maps the z column as needed.

reset

step(x) = (x < 15.0  ? 0 : \
          (x < 35.0  ? 1 : \
          (x < 62.5  ? 2 : \
          (x < 82.5  ? 3 : \
          (x < 92.5  ? 4 : \
          (x < 96.25 ? 5 : \
          (x < 98.25 ? 6 : \
          (x < 99.3  ? 7 : \
          (x < 99.75 ? 8 : 9 )))))))))

set palette maxcolors 10
set palette defined (0 "#333399", 1 "#3333f7", 2 "#3373ff", 3 "#33c6ff", \
                     4 "#5affd2", 5 "#9cff8f", 6 "#dfff4c", 7 "#ffc733", \
                     8 "#ff7a33", 9 "#e53333")

set cbrange [-0.5:9.5]
set cbtics nomirror
set cbtics ( "99.9" 9, "99.6" 8, "99.0" 7, "97.5" 6, "95.0" 5, \
             "90.0" 4, "75.0" 3, "50.0" 2, "20.0" 1, "10.0" 0 )

set terminal pngcairo
set output "output.png"
set xrange [-30:40]
set yrange [ 25:70]
plot "HeatMap_Test.txt" u 2:1:(step($3)) notitle pt 5 ps 2 lc palette, \
     "world_10m.txt" notitle with lines ls 1 lc -1
set output

我多次嵌套三元运算符,以将不规则百分比范围0 ... 100映射为线性cbrange -0.5 ... 9.5.

I have nested the ternary operator several times to map the irregular percentage ranges 0 ... 100 into a linear cbrange -0.5 ... 9.5.

这是Gnuplot 4.6的结果:

This is the result with Gnuplot 4.6:

这篇关于GNUPlot中颜色栏中的不规则百分位数抽动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆