如何在gnuplot中通过数据设置点类型?

7
如何从gnuplot中的数据设置点类型?
gnuplot脚本:
set terminal pngcairo size 640,480
set output "points.png" 
set style data points 
set auto x 
set autoscale x 
unset colorbox 
plot 'test.data' using 2:1 with points notitle

test.data

32  35  8
34  34  6
36  28  1
34  32  2
28  30  7
38  30  9
34  29  2
35  36  9
39  34  3
31  33  9
28  31  6
35  30  5
33  41  4
32  37  3

如何从三列中获取点类型?
plot 'gnuplot.data' using 2:1 with points pt (:3) notitle // error 

抽象化示例:

enter image description here

需求:

enter image description here

gnuplot版本4.6修补程序4

1个回答

12

数据文件中没有根据列选择点类型的选项(相当于linecolor variablepointsize variablearrowstyle variable)。基本上您有两个选择:

  1. Iterate over all possible point types (which you can extract with stats if this should be variable) and for each number plot only those points which match the current point type:

    stats 'test.data' using 3 nooutput
    unset key
    set style data points
    plot for [i=STATS_min:STATS_max] 'test.data' using 2:($3 == i ? $1 : 1/0) lt 1 pt i ps 2
    

enter image description here

  1. Use the labels plotting style and a sequence of unicode point symbols from which you select using the value from the third column as index. (use e.g. http://www.shapecatcher.com or http://decodeunicode.org/en/geometric_shapes to find suitable symbols)

    unset key
    set encoding utf8
    symbol(z) = "•✷+△♠□♣♥♦"[int(z):int(z)]
    plot 'test.data' using 2:1:(symbol($3)) with labels textcolor lt 1
    

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接