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

Axis labels on examples #9

Closed
bryantrobbins opened this issue Jan 2, 2012 · 4 comments
Closed

Axis labels on examples #9

bryantrobbins opened this issue Jan 2, 2012 · 4 comments

Comments

@bryantrobbins
Copy link

It looks to me like the axis labels on your examples are backwards.

For example, from sin_wave.rb

plot.xrange "[-10:10]"
plot.title "Sin Wave Example"
plot.ylabel "x"
plot.xlabel "sin(x)"

Here, x has values -10 to 10, but is labeled "sin(x)". I see the same issue in discrete_points, multiple_data_sets, and output_image_file too.

Am I missing something?

@rdp
Copy link
Owner

rdp commented Jan 3, 2012

does the output from running it look off as well?

@bryantrobbins
Copy link
Author

I'm on Windows so I ran this code to save the plot:

require 'rubygems'
require 'gnuplot'

Gnuplot.open do |gp|
  Gnuplot::Plot.new( gp ) do |plot|
    plot.terminal "png"
    plot.output File.expand_path("../sin_wave.png", __FILE__)

    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"
      ds.linewidth = 4
    end
  end
end

The resulting plot is here: http://www.cs.umd.edu/~brobbins/tmp/sin_wave.png

The Y axis is labeled "x" and X axis labeled "sin(x)". But the plot has sin(x) actually plotted on the Y axis and x on the X axis. This is the typical way of plotting functions in 2D, e.g. https://www.google.com/search?q=plot+of+sin(x)

So I think it's just the labels that are swapped in the code. What's crazy is that this example has been around since the older rgplot days (http://rgplot.rubyforge.org/), so I'm skeptical that I'm probably just overlooking something!

@rdp
Copy link
Owner

rdp commented Jan 4, 2012

My guess is that the original author wanted to have "sin(x)" at the
bottom, 'cause it looks prettier LOL, but...I guess they're flipped
then aren't they? Feel free to hack up a patch for it and submit a
pull request.
-r

On Wed, Jan 4, 2012 at 11:16 AM, bryantrobbins
reply@reply.github.com
wrote:

I'm on Windows so I ran this code to save the plot:

require 'rubygems'
require 'gnuplot'

Gnuplot.open do |gp|
 Gnuplot::Plot.new( gp ) do |plot|
   plot.terminal "png"
   plot.output File.expand_path("../sin_wave.png", FILE)

   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"
     ds.linewidth = 4
   end

 end
end

The resulting plot is here: http://www.cs.umd.edu/~brobbins/tmp/sin_wave.png

The Y axis is labeled "x" and X axis labeled "sin(x)". But the plot has sin(x) actually plotted on the Y axis and x on the X axis. This is the typical way of plotting functions in 2D, e.g. https://www.google.com/search?q=plot+of+sin(x)

So I think it's just the labels that are swapped in the code. What's crazy is that this example has been around since the older rgplot days (http://rgplot.rubyforge.org/), so I'm skeptical that I'm probably just overlooking something!


Reply to this email directly or view it on GitHub:
#9 (comment)

@rdp
Copy link
Owner

rdp commented Mar 20, 2012

ok attempted fix: 34819ac

@rdp rdp closed this as completed Mar 20, 2012
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