【问题标题】:How can the plot symbol be specified in the ruby implementation of gnuplot?如何在 gnuplot 的 ruby​​ 实现中指定绘图符号?
【发布时间】:2014-04-17 09:28:51
【问题描述】:

x,y 数据集的默认绘图符号是红十字。假设我希望它是一个填充的黑色正方形。我该怎么做?

为了清楚说明我在此代码示例中所做的事情,我在(已经指定的)输出路径上使用 gnuplot 设置了一个绘图。它是一个 png,具有指定的大小、字体和字体大小。我稍微调整了左边距和边框厚度,并给我的轴一些标题,但这些是其他美学。

要生成黑线,我会取消注释该注释行。我怎么得到,比如说,填充方块?我无法从http://gnuplot.sourceforge.net/docs_4.6/gnuplot.pdf的 gnuplot 文档中解决它

  ::Gnuplot.open do |gp|
    ::Gnuplot::Plot.new(gp) do |plot|
      plot.terminal "png size 1800,600 font \"arial,20\""
      plot.lmargin "10"
      plot.output "#{star[:wrapped_rv_plot]}"
      plot.border "linewidth 2"
      plot.ylabel "Radial velocity (km/s)"
      plot.xlabel "Orbital Phase"

      x = ext_phase_rv.map { |point| point[0] }
      y = ext_phase_rv.map { |point| point[1] }

      plot.data << ::Gnuplot::DataSet.new([x, y]) do |ds|
        # ds.with = "lines lt rgb \"black\""
        ds.notitle
      end
    end
  end

【问题讨论】:

    标签: ruby gnuplot


    【解决方案1】:

    你得到与linetype 5 的平方点,参见例如Gnuplot line types。要绘制点,请使用with points :)

    ds.with = "points"
    ds.linecolor = "rgb 'blue' linetype 5"
    

    【讨论】:

    • 这并没有完全做到,但它引导我走上了正确的道路。特别是参考测试页。谢谢!
    • 对我来说效果很好,当然我在回答之前测试了它! ruby gnuplot gem 的当前版本甚至允许您使用 ds.linestyle 并定义正确的线条样式。
    【解决方案2】:

    用下面的代码替换注释行将产生黑色方块。有关更多“pt”(点类型)示例的链接,请参阅 Christoph 的回答。

    ds.with = "points lc rgb 'black' pt 5"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-03
      相关资源
      最近更新 更多