Wayne
Wayne

Reputation: 1

Plotly Express - how to set date slider on x,y scatter plot

I'm trying to make a scatter plot that allows me to do a couple things:

  1. Toggle a selected date range that automatically displays the coordinates for each day within the range - I figure some sort of slider would be used, but haven't been able to get one to work.
  2. Identify the start and end date - I've thought about using a heatmap to show the coordinates path over the date range

Here is some of the data:

Date x y 2024-10-09 0.08 4.83 2024-10-16 0.01 4.83 2024-10-23 0.28 4.83 2024-10-30 0.24 4.83 2024-11-06 0.32 4.83 2024-11-13 0.64 4.62 2024-11-20 0.62 4.58 2024-11-27 0.49 4.58 2024-12-04 0.39 4.58 2024-12-11 0.52 4.58

The basic scatter plot works:

fig = px.scatter(df, x="x", y="y", width=600, height=600,
                range_x=[df['x'].min(), df['x'].max()], range_y=[df['y'].min(), df['y'].max()])

I set the min and max because eventually I will later move the origin to the median values of x and y.

fig.update_layout(xaxis=dict(rangeslider=dict(visible=True), type="date"))

Thanks for any help.

Upvotes: 0

Views: 29

Answers (0)

Related Questions