Skip to content

Instantly share code, notes, and snippets.

@arafatkatze
Last active August 20, 2018 05:15
Show Gist options
  • Save arafatkatze/9cce2c4d10f3711204dd6ba7db153616 to your computer and use it in GitHub Desktop.
Save arafatkatze/9cce2c4d10f3711204dd6ba7db153616 to your computer and use it in GitHub Desktop.
require 'rubyplot'
@x1 = []
@y1 = []
for i in 0..1000
num = Float(i) / Float(500)
puts num
x = Math.sin(num * Math::PI)
x = 16 * x * x * x
y = 13 * Math.cos(num * Math::PI) - 5 * Math.cos(2 * num * Math::PI) - 2 * Math.cos(3 * num * Math::PI) - 4 * Math.cos(num * Math::PI)
@x1.push(10 * x)
@y1.push(10 * y)
end
g = Rubyplot::Figure.new(backend: :magick)
g.scatter! @x1, @y1, marker_color: :pink, label: :heart
g.save('scatter.png')
g2 = Rubyplot::Figure.new(backend: :GR)
g2.text_font = :bookman_light_italic
g2.scatter! @x1, @y1, marker_color: :red
g2.save('scatter2.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment