1

The default plot symbol for an x,y dataset is a red cross. Let's say I'd like it to be a filled, black square. How do I do that?

To be transparent about what I'm doing in this code example, I set up a plot using gnuplot at the (already-specified) output path. It's a png, with a specified size, font and fontsize. I fiddle a bit with the left margin and border thickness and give my axes some titles, but those are other aesthetics.

To generate black lines, I would uncomment that one commented line. How do I get, say, filled squares though? I cannot work it out from the gnuplot documentation at http://gnuplot.sourceforge.net/docs_4.6/gnuplot.pdf

  ::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
sjmurphy
  • 686
  • 1
  • 5
  • 6

2 Answers2

1

You get squared points with linetype 5, see e.g. Gnuplot line types. To plot with points, use with points :)

ds.with = "points"
ds.linecolor = "rgb 'blue' linetype 5"
Community
  • 1
  • 1
Christoph
  • 47,569
  • 8
  • 87
  • 187
  • That didn't quite do it, but it led me along the right track. Particularly with the reference to the test page. Thanks! – sjmurphy Apr 17 '14 at 01:27
  • 1
    For me it works fine, of course I tested it before answering! The current version of the [ruby gnuplot gem](https://github.com/rdp/ruby_gnuplot/blob/master/lib/gnuplot.rb) even allows you to use `ds.linestyle` and define proper line styles. – Christoph Apr 18 '14 at 18:09
0

Replacing the commented line with the code below will produce black squares. Please see Christoph's answer for a link to more 'pt' (point type) examples.

ds.with = "points lc rgb 'black' pt 5"
sjmurphy
  • 686
  • 1
  • 5
  • 6