Skip to content

Instantly share code, notes, and snippets.

@arafatkatze
Created August 20, 2018 04:42
Show Gist options
  • Save arafatkatze/e1b745707ee82aa3f302bcc1b84cd703 to your computer and use it in GitHub Desktop.
Save arafatkatze/e1b745707ee82aa3f302bcc1b84cd703 to your computer and use it in GitHub Desktop.
require 'rubyplot'
@datasets = [
[[20, 10, 5, 12, 11, 6, 10, 7], :Anna],
[[5, 10, 20, 6, 9, 12, 14, 8], :Jack],
[[19, 9, 6, 11, 12, 7, 15, 8], :Katie]
]
plot = Rubyplot::StackedBar.new(1000)
plot.title = 'Net earnings in different months'
plot.labels = {
0 => 'Jan',
1 => 'Feb',
2 => 'March',
3 => 'April',
4 => 'May',
5 => 'June',
6 => 'July',
7 => 'August',
8 => 'September',
9 => 'October',
10 => 'November',
11 => 'December'
}
@datasets.each do |data|
plot.data data[0], label: data[1]
end
plot.write('stacked_bar_test_1.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment