Created
July 2, 2017 12:28
-
-
Save AlexWheeler/2733dbbb1670754f3de41873788d9bfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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