Plotly express strip plot does not separate the points by color when temporal data is used on the x-axis.
Set up some data with random groups and status (which will be the color of points in our plot)
import pandas as pd
import plotly.express as px
import random
random.seed(0)
n = 100
df = pd.DataFrame(
data=dict(
group=random.choices(["A","B","C"], k=n),
status=random.choices(["on", "off"], k=n),
time=pd.date_range('2/5/2019', periods = n, freq ='2H'),
)
)
Our DataFrame is
print(df)
group status time
0 C off 2019-02-05 00:00:00
1 C off 2019-02-05 02:00:00
2 B on 2019-02-05 04:00:00
3 A off 2019-02-05 06:00:00
4 B on 2019-02-05 08:00:00
.. ... ... ...
95 C on 2019-02-12 22:00:00
96 C off 2019-02-13 00:00:00
97 A on 2019-02-13 02:00:00
98 B off 2019-02-13 04:00:00
99 B on 2019-02-13 06:00:00
[100 rows x 3 columns]
When we go to make a strip plot with "time" as the x-axis, using status as the color, all status values are on the same y-level
px.strip(df, x="time", y="group", color="status")
But if we were to use the DataFrame's integer indices as the x-axis, the colors are placed on different y levels
px.strip(df.reset_index(), x="index", y="group", color="status")
I would like the temporal data to plot like the integer data (with different colors on different y levels). I see nothing in the documentation that says temporal data is an issue.



Certainly, there's a simpler way to achieve your desired result, but one alternative solution is to create the strip plot using integer indices as the x-axis and then update the tick labels to the datetime values.
The downside of this solution is that certain things that
plotlyusually manages automatically for you, like tick labels spacing, will now have to be handled manually by your code.Here's the source code for this approach:
Output: