Multiple marker styles for a line graph

Hello, is there a way to apply different styling to markers on the same line?
Iโ€™m logging the prices of an Item and sometimes the price is not available so Iโ€™d like to change from a circle marker to a x marker when the price is not available.
I already tried creating two separate lines but they intersect and the result isnโ€™t great

Thanks in advance.


Adding a separate scatter plot doesnโ€™t really help. I just want to change marker type based on a condition

Welcome to the forums, @Francesco_Boraso

You can specify the markers directly, you would just need to create the marker symbol list beforehand.

import plotly.graph_objects as go

fig = go.Figure()
fig.add_scatter(
    x=[1,2,3], 
    y=[1,2,3], 
    mode="markers+lines",
    marker_symbol=["cross", "circle", "square"],
    marker_size=[10, 20, 30],
    marker_color=["red", "yellow", "black"]
)
fig.show()

import plotly.graph_objects as go

price = [10, 0, 20, 30, 2 , 0]

fig = go.Figure()
fig.add_scatter(
    y=price, 
    x=[*range(len(price))], 
    mode="markers+lines",
    marker_symbol=[["cross", "circle"][item!=0] for item in price],
    marker_color=[["red", "blue"][item!=0] for item in price],

)
fig.update_yaxes(title="price")
fig.show()