Skip to content

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

Merged
midhun-pm merged 2 commits into
masterfrom
fix/bar_plot_stacked_example
Jan 2, 2020
Merged

Fix stacked bar plot example, by using the correct starting_value#498
midhun-pm merged 2 commits into
masterfrom
fix/bar_plot_stacked_example

Conversation

@midhun-pm
Copy link
Copy Markdown
Contributor

Fixes #444

Comment thread examples/demo/basic/bar_plot_stacked.py Outdated

index = numpy.array([1,2,3,4,5])
demo = PlotExample(index, index*10, index*5, index*2)
demo = PlotExample(index, index*10, index*15, index*17)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to do this without changing the input data?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring for starting_value says the following:

    #: The data source to use as "starting" values for bars (along value axis).
    #: For instance, if the values are [10, 20] and starting_value
    #: is [3, 7], BarPlot will plot two bars, one  between 3 and 10, and
    #: one between 7 and 20

I think BarPlot is designed not to change the value when stacking, so the user may have to do it explicitly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could reverse the input data instead. The original version of this relied on the rendering order (the tallest bar was drawn first, etc.).

Even better might be to sum the data as part of the process of creating the plots (ie. barplot 1 is from 0 to series_a, barplot 2 is from series_a to series_a + series_b, etc.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, that's better, made the change.

Copy link
Copy Markdown
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to have this merged as is; feel free to modify if desired.

@midhun-pm midhun-pm merged commit 2000cd7 into master Jan 2, 2020
@rahulporuri rahulporuri deleted the fix/bar_plot_stacked_example branch October 27, 2020 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bar_plot_stacked example unfinished?

3 participants