Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stacked bar plot example, by using the correct starting_value #498

Merged
merged 2 commits into from
Jan 2, 2020
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