Ruby:构建一个功能图 [英] Ruby: building a plot of function
问题描述
在Ruby下构建函数图的最简单方法是什么?有关特殊图形库的任何建议?
update:仅适用于Windows: - (
)更新2:发现以下gem是目前为止的最佳解决方案 https: //github.com/clbustos/rubyvis
What's the easiest way to build a plot of a function under Ruby? Any suggestions as to the special graphical library? update: under windows only :-( update 2: found the following gem as a best solution so far https://github.com/clbustos/rubyvis Is
这篇关于Ruby:构建一个功能图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
<$ p $ ($ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $' testgnu.pdf
plot.terminalpdf颜色尺寸27cm,19cm
plot.xrange[-10:10]
plot.titleSin Wave Example
plot.ylabelx
plot.xlabelsin(x)
plot.data<<< Gnuplot :: DataSet.new(sin(x) ){| ds |
ds.with =lines
ds.linewidth = 4
}
plot.data<< Gnuplot :: DataSet.new(cos(x)){| ds |
ds.with =冲动
ds.linewidth = 4
}
}
}
gnuplot
a possible option?:require 'gnuplot.rb'
Gnuplot.open { |gp|
Gnuplot::Plot.new( gp ) { |plot|
plot.output "testgnu.pdf"
plot.terminal "pdf colour size 27cm,19cm"
plot.xrange "[-10:10]"
plot.title "Sin Wave Example"
plot.ylabel "x"
plot.xlabel "sin(x)"
plot.data << Gnuplot::DataSet.new( "sin(x)" ) { |ds|
ds.with = "lines"
ds.linewidth = 4
}
plot.data << Gnuplot::DataSet.new( "cos(x)" ) { |ds|
ds.with = "impulses"
ds.linewidth = 4
}
}
}