【问题标题】:How set point type from data in gnuplot?如何从 gnuplot 中的数据中设置点类型?
【发布时间】:2015-06-19 19:12:01
【问题描述】:

如何从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

【问题讨论】:

    标签: gnuplot points pt


    【解决方案1】:

    没有选项可以根据列从数据文件中选择点类型(相当于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
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-28
      • 1970-01-01
      • 2015-01-13
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      相关资源
      最近更新 更多