In [1]:
# Basic Bar Chart
require 'rbplotly'

trace = { 
  x: %w(giraffes orangutans monkeys),
  y: [20, 14, 23],
  type: :bar
}

plot = Plotly::Plot.new(data: [trace])
plot.show



In [2]:
# Grouped Bar Chart
require 'rbplotly'

trace1 = {
  x:    %w(giraffes orangutans monkeys),
  y:    [20, 14, 23],
  type: :bar,
  name: 'SF Zoo'
}
trace2 = {
  x:    %w(giraffes orangutans monkeys),
  y:    [12, 18, 29],
  type: :bar,
  name: 'LA Zoo'
}

plot = Plotly::Plot.new(data: [trace1, trace2])
plot.show



In [3]:
# Grouped to Stacked
plot.layout.barmode = :stack
plot.show



In [4]:
# Stacked Bar Chart
require 'rbplotly'

trace1 = {
  x:    %w(giraffes orangutans monkeys),
  y:    [20, 14, 23],
  type: :bar,
  name: 'SF Zoo'
}
trace2 = {
  x:    %w(giraffes orangutans monkeys),
  y:    [12, 18, 29],
  type: :bar,
  name: 'LA Zoo'
}

plot = Plotly::Plot.new(data: [trace1, trace2], layout: { barmode: :stack } )
plot.show



In [ ]: