【问题标题】:gnuplot specify column for labelgnuplot 为标签指定列
【发布时间】:2013-12-17 01:24:09
【问题描述】:

我正在 gnuplot 中进行多重绘图。我想从某些列中选择点的标签。例如,假设数据文件是:

 year temp label1 year humidity label2
 1990 30   hot    1991 100      wet
 1992 25   warm   1992 83       dry

我想使用第 3 列 (label1) 作为点的标签来绘制第 2 列(温度)与第 1 列(年份),并在同一图表上使用第 6 列( label2) 作为标签。这可能吗?

  plot 'weather.dat' using 1:2 with points with labels, '' using 4:5 with points with labels

【问题讨论】:

    标签: plot gnuplot


    【解决方案1】:

    使用标签样式。此样式期望接收 x 和 y 坐标以及标签列。

    对于您的数据,以及情节的第一部分,我们可以做

    plot 'weather.data' using 1:2 with points, '' using 1:2:3 with labels
    

    如果我们想增加一点间距,我们可以调整标签的 y 坐标。例如,将其向上移动 1 个单位

    plot 'weather.data' using 1:2 with points, '' using 1:($2+1):3 with labels
    

    对于这个情节,为了确保一切都完全适合,我手动将 xrange 设置为 [1989:1993] 并将 yrange 设置为 [20:35]。

    类似的方法适用于您的其他数据列,当然,这些数据列可以正常结合(尽管 y 范围有很大不同,可能应该在它自己的图上完成,或使用辅助轴) .

    请参阅help labels 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-19
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多