Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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