Skip to content

Providing support for multiplot #11

Description

@pddzaic

Is it possible to create multi plots?

Activity

  1. rdp commented on May 22, 2012

    @rdp
    Owner

    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

  2. akemrir commented on Jan 22, 2013

    @akemrir

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

  3. rvlasveld commented on Mar 6, 2013

    @rvlasveld

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

  4. rvlasveld commented on Mar 7, 2013

    @rvlasveld

    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?

  5. rvlasveld commented on Mar 7, 2013

    @rvlasveld

    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.

  6. akemrir commented on Mar 23, 2013

    @akemrir

    nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions