I have the following stack bar chart where the last bar comes from a different pandas dataframe. I now want to highlight the last bar since to emphasize the fact that its data comes from a different dataframe.
How do I do this? Thanks in advance for any helps.
jmmease
January 22, 2019, 11:00am
2
Hi @chainster_mike ,
One thing you could do is to draw a thick colored border around the bars all the way to the right. Something like:
import plotly.graph_objs as go
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode()
trace1 = go.Bar(
x=['giraffes', 'orangutans', 'monkeys'],
y=[20, 14, 23],
name='SF Zoo'
)
trace2 = go.Bar(
x=['giraffes', 'orangutans', 'monkeys'],
y=[12, 18, 29],
name='LA Zoo'
)
data = [trace1, trace2]
layout = go.Layout(
barmode='stack'
)
# Draw border around last bars
for bar in data:
bar.marker.line.color = 'red'
bar.marker.line.width = [0, 0, 4]
fig = go.Figure(data=data, layout=layout)
iplot(fig)
Hope that helps!
-Jon
Thank you! This is exactly what I wanted.
1 Like