加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Ruby:构建功能图

发布时间:2020-12-16 23:18:09 所属栏目:百科 来源:网络整理
导读:在 Ruby下构建函数图的最简单方法是什么?有关特殊图形库的任何建议吗? 更新:仅在Windows下:-( 更新2:发现以下宝石作为迄今为止https://github.com/clbustos/rubyvis的最佳解决方案 解决方法 gnuplot 是可能的选择吗?: require 'gnuplot.rb'Gnuplot.ope
在 Ruby下构建函数图的最简单方法是什么?有关特殊图形库的任何建议吗?

更新:仅在Windows下:-(

更新2:发现以下宝石作为迄今为止https://github.com/clbustos/rubyvis的最佳解决方案

解决方法

gnuplot是可能的选择吗?:
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
        }
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读