Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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