Guest User

Untitled

a guest
Apr 25th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. require 'gnuplot.rb'
  2. Gnuplot.open { |gp|
  3. Gnuplot::Plot.new( gp ) { |plot|
  4. plot.output "testgnu.pdf"
  5. plot.terminal "pdf colour size 27cm,19cm"
  6.  
  7. plot.xrange "[-10:10]"
  8. plot.title "Sin Wave Example"
  9. plot.ylabel "x"
  10. plot.xlabel "sin(x)"
  11.  
  12. plot.data << Gnuplot::DataSet.new( "sin(x)" ) { |ds|
  13. ds.with = "lines"
  14. ds.linewidth = 4
  15. }
  16. plot.data << Gnuplot::DataSet.new( "cos(x)" ) { |ds|
  17. ds.with = "impulses"
  18. ds.linewidth = 4
  19. }
  20. }
  21. }
  22.  
  23. require 'SVG/Graph/Line'
  24.  
  25. fields = %w(Jan Feb Mar);
  26. data_sales_02 = [12, 45, 21]
  27. data_sales_03 = [15, 30, 40]
  28.  
  29. graph = SVG::Graph::Line.new({
  30. :height => 500,
  31. :width => 300,
  32. :fields => fields,
  33. })
  34.  
  35. graph.add_data({
  36. :data => data_sales_02,
  37. :title => 'Sales 2002',
  38. })
  39.  
  40. graph.add_data({
  41. :data => data_sales_03,
  42. :title => 'Sales 2003',
  43. })
  44.  
  45. print "Content-type: image/svg+xmlrnrn";
  46. print graph.burn();
  47.  
  48. require 'rubygems'
  49. require 'gnuplot'
  50.  
  51. Gnuplot.open do |gp|
  52. Gnuplot::Plot.new( gp ) do |plot|
  53.  
  54. plot.xrange "[-10:10]"
  55. plot.title "Sin Wave Example"
  56. plot.ylabel "x"
  57. plot.xlabel "sin(x)"
  58.  
  59. plot.data << Gnuplot::DataSet.new( "sin(x)" ) do |ds|
  60. ds.with = "lines"
  61. ds.linewidth = 4
  62. end
  63. end
  64. end
Add Comment
Please, Sign In to add comment