In [1]:
File.open('tons_of_data', 'w') do |f|
(1..100000).each do |x|
xx = x/1000.0
yy = Math.exp(Math.sin(xx))
f.puts "#{xx} #{yy}"
end
end
Out[1]:
In [2]:
require 'gnuplotrb'
include GnuplotRB
Plot.new(['tons_of_data', title: 'Tons of data', with: 'lines'])
Out[2]:
In [3]:
include Math
def butterfly_point(angle)
8 -
1.2 * sin(angle) +
2 * sin(3 * angle) +
2 * sin(5 * angle) -
sin(7 * angle) +
0.8 * sin(9 * angle) -
0.3 * sin(11 * angle) +
4.8 * cos(2 * angle) -
2 * cos(4 * angle) +
0.8 * cos(13.2 * angle)
end
θ = (0.0..10*PI).step(0.01).to_a
r = θ.map { |angle| butterfly_point(angle) }
butterfly = Plot.new(
[[θ,r], notitle: true, with: 'filledcurve', lt: {rgb: '#BCECFF'}],
[[θ,r], title: 'Butterfly', with: 'lines', lt: {rgb: '#422515', lw: 2}],
polar: true
)
Out[3]: