8000 [BUG] vbar_stack with positive and negative values does not plot correctly · Issue #9011 · bokeh/bokeh · GitHub
[go: up one dir, main page]

Skip to content
[BUG] vbar_stack with positive and negative values does not plot correctly #9011
@JING1201

Description

@JING1201

Expected Behavior:
When the source data contain a mixture of positive and negative values, the bars with negative values will stack downward below 0 without interfering the positive bars.

Observed Behavior:
When the source data contain a mixture of positive and negative values, the bars with negative values stack downward from the top of the previous positive bar, making that bar not visible.

Note: This is similar to the issue raised in plotly , and this is resolved by having a 'relative' barmode.

Software versions:
bokeh 1.2.0
Python 3.6.8

OS:
Windows 10

Example:

from bokeh.plotting import figure, show, save
from bokeh.io import output_notebook
from bokeh.core.properties import value
from bokeh.layouts import *

y_s = ['y1', 'y2']
data = {'x_values': [1, 2, 3, 4, 5],
       'y1': [-2, 5, 1, -2, 3], 
       'y2': [1, -9, -5, 1, -2]}
p = figure(title="Demonstration")
p.vbar_stack(['y1', 'y2'], x='x_values', width = 0.5, color = ['blue','red'], source = data, legend=[value(y) for y in y_s])
p.legend.click_policy="hide"
show(p)

image

Expected Output:

image

Although using separate vbar glyphs can solve the issue in this example, it will not be much help when there are more stacked bars and the data gets more complicated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0