Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing support for multiplot #11

Open
pddzaic opened this issue May 22, 2012 · 6 comments
Open

Providing support for multiplot #11

pddzaic opened this issue May 22, 2012 · 6 comments

Comments

@pddzaic
Copy link

pddzaic commented May 22, 2012

Is it possible to create multi plots?

@rdp
Copy link
Owner

rdp commented May 22, 2012

looks like "not yet" though you can put multiple lines into a single graph: https://github.com/rdp/ruby_gnuplot/blob/master/examples/multiple_data_sets.rb

@akemrir
Copy link

akemrir commented Jan 22, 2013

anything changed in this case?
I`am interested too, in multiple plots in one document.

@rvlasveld
Copy link

Maybe in hope to get attention to this one, I would also very much like support for multiplots.

@rvlasveld
Copy link

I would like to put some work in trying to fix this, but I am fairly inexperienced with this kind of programming. Can someone maybe give me a few pointers for the steps which need to be taken?

@rvlasveld
Copy link

Actually, I just discovered this is possible already. It is a bit of a work-around, because you have to set the multilayout in the first Gnuplot::Plot you define. The following works:

require '../lib/gnuplot'
$VERBOSE = true
Gnuplot.open do |gp|

  Gnuplot::Plot.new(gp) do |plot|
    plot.multiplot "layout 2,1"
    plot.xrange "[-10:10]"
    plot.title  "Sin Wave Example"
    plot.ylabel "x"
    plot.xlabel "sin(x)"

    plot.data << Gnuplot::DataSet.new( "sin(x)" ) do |ds|
      ds.with = "lines lc rgb 'blue'"
      ds.linewidth = 4
    end
  end

  Gnuplot::Plot.new(gp) do |plot|
    plot.xrange "[-10:10]"
    plot.title  "Second sin Wave Example"
    plot.ylabel "x"
    plot.xlabel "sin(x)"

    plot.data << Gnuplot::DataSet.new( "sin(x)" ) do |ds|
      ds.with = "lines lc rgb 'green'"
      ds.linewidth = 4
    end
  end
end

Because this is a "global" Gnuplot setting, it would be better to have this implemented on the level of Gnuplot. The resulting class should probably have the methods method_missing, set and unset implemented, together with a @settings like Gnuplot::Plot does. Because this is quite a repetition, a nicer solution can be found than just copy the code, maybe?

Note that any global setting can be provided this way. An other, very ugly, solution would be to direct insert command to the gp object:

Gnuplot.open do |gp|
   gp << "set multiplot layout 2,1\n"
  Gnuplot::Plot.new(gp) do |plot|
  end
end

Note the \n.

@akemrir
Copy link

akemrir commented Mar 23, 2013

nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants