# Highlight the last bar of a stack bar chart

**URL:** <https://community.plotly.com/t/highlight-the-last-bar-of-a-stack-bar-chart/18414>\
**Category:** 📊 Plotly Python\
**Created:** [January 22, 2019, 6:41am UTC](https://community.plotly.com/t/highlight-the-last-bar-of-a-stack-bar-chart/18414 "2019-01-22T06:41:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chainster\_mike](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@chainster\_mike](https://community.plotly.com/u/chainster_mike)\
**Post date:** [January 22, 2019, 6:41am UTC](https://community.plotly.com/t/highlight-the-last-bar-of-a-stack-bar-chart/18414/1 "2019-01-22T06:41:48Z")

</div>

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.

 ![newplot%20(2)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/9/95eddc1d5086c5f511312f7eeb67d30eaed48082.png)

How do I do this? Thanks in advance for any helps.

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [January 22, 2019, 11:00am UTC](https://community.plotly.com/t/highlight-the-last-bar-of-a-stack-bar-chart/18414/2 "2019-01-22T11:00:15Z")

</div>

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:

```python
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)

```

 ![newplot%20(13)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/1/16f2599bc209584cdcf2c19e9966fc4a5fa5153a.png)

Hope that helps!  
-Jon

---

<div class="post-metadata">

**Author:** ![chainster\_mike](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@chainster\_mike](https://community.plotly.com/u/chainster_mike)\
**Post date:** [January 23, 2019, 5:14am UTC](https://community.plotly.com/t/highlight-the-last-bar-of-a-stack-bar-chart/18414/3 "2019-01-23T05:14:08Z")

</div>

Thank you! This is exactly what I wanted.
