Skip to content

Commit

Permalink
Merge pull request #498 from enthought/fix/bar_plot_stacked_example
Browse files Browse the repository at this point in the history
Fix stacked bar plot example
  • Loading branch information
midhun-pm authored Jan 2, 2020
2 parents eabfe82 + dc24db1 commit 2000cd7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/demo/basic/bar_plot_stacked.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from traitsui.api import UItem, View

# Chaco imports
from chaco.api import LabelAxis, Plot, ArrayPlotData
from chaco.api import LabelAxis, Plot, ArrayPlotData, ArrayDataSource

class PlotExample(HasTraits):
plot = Instance(Plot)
Expand All @@ -22,14 +22,18 @@ class PlotExample(HasTraits):
def __init__(self, index, series_a, series_b, series_c, **kw):
super(PlotExample, self).__init__(**kw)

# Stack them up
series_c = series_c + series_b + series_a
series_b = series_b + series_a

plot_data = ArrayPlotData(index=index)
plot_data.set_data('series_a', series_a)
plot_data.set_data('series_b', series_b)
plot_data.set_data('series_c', series_c)
self.plot = Plot(plot_data)
self.plot.plot(('index', 'series_a'), type='bar', bar_width=0.8, color='auto')
self.plot.plot(('index', 'series_b'), type='bar', bar_width=0.8, color='auto')
self.plot.plot(('index', 'series_c'), type='bar', bar_width=0.8, color='auto')
self.plot.plot(('index', 'series_b'), type='bar', bar_width=0.8, color='auto', starting_value=ArrayDataSource(series_a))
self.plot.plot(('index', 'series_c'), type='bar', bar_width=0.8, color='auto', starting_value=ArrayDataSource(series_b))

# set the plot's value range to 0, otherwise it may pad too much
self.plot.value_range.low = 0
Expand Down

0 comments on commit 2000cd7

Please sign in to comment.