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

Plotting vectors #36

Open
maasha opened this issue Oct 24, 2014 · 2 comments
Open

Plotting vectors #36

maasha opened this issue Oct 24, 2014 · 2 comments

Comments

@maasha
Copy link
Contributor

maasha commented Oct 24, 2014

I would like to get this example to work using ruby_gnuplot:

http://stackoverflow.com/questions/16541040/how-do-i-use-gnuplot-to-plot-a-simple-2d-vector-arrow

However, my attempt is not working. I think the problem is, I don't know what Dataset.new does. If this could be fixed, I would like to contribute it to the /examples.

#!/usr/bin/env ruby

require 'gnuplot'

data = [
  [0, 0,  0.5, 0.5],
  [0, 1, -0.5, 0.5],
  [1, 1,  1,   0]
]

Gnuplot.open do |gp|
  Gnuplot::Plot.new(gp) do |plot|
    plot.term   "dumb"
    plot.output "/dev/stderr"

    plot.data << Gnuplot::DataSet.new(data) do |ds|
      ds.using = "1:2:3:4"
      ds.with  = "vectors filled head lw 3"
    end
  end
end
@rdp
Copy link
Owner

rdp commented Oct 27, 2014

if it gets really impossible you can always just cut a gnuplot "raw" file
instead of using the gem...for super complex things I do that.

On Fri, Oct 24, 2014 at 10:07 AM, maasha [email protected] wrote:

I would like to get this example to work using ruby_gnuplot:

http://stackoverflow.com/questions/16541040/how-do-i-use-gnuplot-to-plot-a-simple-2d-vector-arrow

However, my attempt is not working. I think the problem is, I don't know
what Dataset.new does. If this could be fixed, I would like to contribute
it to the /examples.

#!/usr/bin/env ruby

require 'gnuplot'

data = [
[0, 0, 0.5, 0.5],
[0, 1, -0.5, 0.5],
[1, 1, 1, 0]
]

Gnuplot.open do |gp|
Gnuplot::Plot.new(gp) do |plot|
plot.term "dumb"
plot.output "/dev/stderr"

plot.data << Gnuplot::DataSet.new(data) do |ds|
  ds.using = "1:2:3:4"
  ds.with  = "vectors filled head lw 3"
end

end
end


Reply to this email directly or view it on GitHub
#36.

@maasha
Copy link
Contributor Author

maasha commented Oct 27, 2014

Plotting a bunch of vectors should be dead simple. I acknowledge that GNUplot is not easily modelled with Ruby, which is a shame.

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

2 participants