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

测试数据

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

如何从 3 列获取点类型?

plot 'gnuplot.data' using 2:1 with points pt (:3) notitle // error 

抽象示例:

在此处输入图像描述

需要:

在此处输入图像描述

gnuplot 版本 4.6 补丁级别 4

4

1 回答 1

11

没有选项可以根据列从数据文件中选择点类型(等效于linecolor variablepointsize variablearrowstyle variable。基本上你有两个选择:

  1. 遍历所有可能的点类型(stats如果这应该是可变的,您可以提取)并且对于每个数字仅绘制与当前点类型匹配的点:

    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
    

在此处输入图像描述

  1. 使用labels绘图样式和一系列 unicode 点符号,您可以使用第三列中的值作为索引从中选择。(使用例如http://www.shapecatcher.comhttp://decodeunicode.org/en/geometric_shapes来查找合适的符号)

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

在此处输入图像描述

于 2015-04-14T10:07:26.323 回答