Created
May 2, 2010 16:25
-
-
Save phosphene/387258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rsruby' | |
r = RSRuby.instance | |
# mod of Peter Lane's Ruby for Scientific Research plot example | |
# construct data to plot, graph of x vs exp(x) | |
xs = 10.times.collect {|i| i} | |
ys = xs.collect {|x| r.exp(x)} | |
r.png("exp_example.png") # tell R we will create png file | |
r.plot(:x => xs, | |
:y => ys, # (x,y) coordinates to plot | |
:type=> "o", # draw a line through points | |
:col=> "blue", # colour the line blue | |
:main=> "Plot of x against exp(x)", # add title to graph | |
:xlab => "x", :ylab => "exp(x)") # add labels to axes | |
r.eval_R("dev.off()") # finish the plotting |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment