I've created a scatterplot with plotly express and now I'd like to highlight a single data point marked by a red star (*) like in the picture attached Return vs. Risk
fig = px.scatter(portfolioDfs, x="Risk", y="Return", color="Sharpe Ratio")
and my data points for highlighting are
x=portfolioDfs.iloc[[highestSharpeRatio][0]]["Risk"], y=portfolioDfs.iloc[[highestSharpeRatio][0]]["Return"]
Any ideas how I can update the fig ?
This isn't really highlighting an already existing data point within a trace you've already produced, but rather adding another one with a different visual appearance. But it does exactly what you're looking for:
fig.add_trace(go.Scatter(x=[3.5], y=[6.5], mode = 'markers',
marker_symbol = 'star',
marker_size = 15))
import plotly.express as px
import pandas as pd
import plotly.graph_objects as go
df = px.data.iris() # iris is a pandas DataFrame
fig = px.scatter(df, x="sepal_width", y="sepal_length")
fig.add_trace(go.Scatter(x=[3.5], y=[6.5], mode = 'markers',
marker_symbol = 'star',
marker_size = 15))
fig.show()