Highlight one or more points in distplot

Hi,

I have an array of daily average temperatures. I am plotting my data using the create_distplot() function.

Is there a way to highlight the latest entry of the array i.e. the most recent value? What I mean by highlight is the to have a colored marker e.g.a red β€œX” in the bar below the histogram and color the respective box of the histogram.

Thanks!

best for #api:python

1 Like

@mr.t

It’s not straightforward to update the distplot such that to highlight the last recorded temperature.
I created this Jupyter notebook https://plot.ly/~empet/14938 to explain the steps to perform such an update.

1 Like

Awesome, thanks!

Can I somehow add a red vertical line on top of the histogram to better visualize the bar that it belongs to?

You can add one more trace for that red vertical line, but unfortunately we don’t know its height.

onemore_trace=dict(type='scatter',
                   x=[d['temp'][-1], d['temp'][-1]],
                   y=[0, height],
                   mode='lines',
                   line=dict(color='red', width=1.5),
                   xaxis='x',
                   yaxis='y')
2 Likes

for visualization purposes the height can be found as shown below:

height = fw.data[1].y.max() * 1.1
onemore_trace=dict(type='scatter',
                   x=[d['temp'][-1], d['temp'][-1]],
                   y=[0, height],
                   mode='lines',
                   line=dict(color='red', width=1.5),
                   xaxis='x',
                   yaxis='y')

x 1.1 to make it stand out :wink:

1 Like