In the following contrived code (in order to comply with MRE) I find that the first 3 markers in the output are unaffected by the update_traces specification.
Code:
import plotly.express as px
import random
import pandas as pd
if __name__ == "__main__":
data = {
"Value": [],
"Date": []
}
for i in range(10):
data["Value"].append(i + random.randint(1, 10))
data["Date"].append(i)
df = pd.DataFrame(data)
fig = px.scatter(
df, x="Date", y="Value", trendline="ols", trendline_color_override="orangered"
)
fig.add_hline(y=df["Value"].iloc[0], line_color="darkgray")
fig.update_traces(marker=dict(size=10, line=dict(width=2, color=(0, 0, 0))))
fig.update_traces(selector=dict(mode="markers"))
fig.show()
I expect all markers in the output to be the same in terms of colour, size and border.
This is code is contrived just to demonstrate the issue. In my real code (far more data points), it’s always the first 3 markers that appear as they would by default.
Is this a bug or have I missed something in my code?
Platform:
macOS 14.5 (M2)
Python 3.12.3
plotly 5.22.0
pandas 2.2.2