2016-11-30 85 views
2

我有一個文本文件,其中包含三列:緯度,經度和百分比。該文本文件看起來像這樣(鏈接here):GNUPlot中colorbar中的不規則百分位tics

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 
... 

我想繪製這個pertentages作爲一個世界地圖(世界地圖GNUPLOT文件頂部的熱圖可以從網站作者here下載)

問題出在色條上,我想按不規則區域(百分位數)對這些值進行分組。由於這是很難解釋,我附上,如果我與GNUPLOT得到的圖像,並與期望的結果另一個情節:

GNUPLOT嘗試: enter image description here

的代碼生成的情節是:

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 

所需的結果: enter image description here

從GNUPLOT的顏色(他們是不是最終的)

此外,你可以看到顏色條抽動s線性分佈(使得99.0以上的所有參數都保持一致),而不是由colorbar定義的區域分組。

有沒有辦法在GNUPlot中做這個陰謀?

回答

3

您可以根據需要定義一個可以映射z列的step函數。

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。

這是gnuplot的4.6結果:

irregular percentile tics

+0

哇!非常感謝你!它工作完美!你甚至有正確的顏色!最後一點評論:有沒有辦法使邊界線符合圖像的大小? – AwkMan