Skip to content

Instantly share code, notes, and snippets.

@AlexWheeler
Created July 2, 2017 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexWheeler/2733dbbb1670754f3de41873788d9bfb to your computer and use it in GitHub Desktop.
Save AlexWheeler/2733dbbb1670754f3de41873788d9bfb to your computer and use it in GitHub Desktop.
require 'gruff'
g = Gruff::Line.new(400)
g.maximum_value = 100
g.minimum_value = 0
g.y_axis_increment = 5
g.theme = {
:colors => %w(black red),
:marker_color => 'grey',
:font_color => 'black',
:background_colors => 'transparent'
}
# results may vary slightly due to pseudorandomness.
real_data = (0..100).map { (1..100).count { open?(0.5) } }
g.data(:real, real_data)
g.data(:target, Array.new(100,50))
g.write('line_transparent.png')
def open?(percentage)
rand < percentage
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment