Hello @AIMPED. From my understanding this is what @dataturnsmeon want.
showlegend False
and you have your fake legend.
Base on your work, you can automate it and put it where you want.
import plotly.express as px
color = { 'setosa':'lightsalmon','versicolor':'lightseagreen','virginica':'royalblue'}
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species",
size='petal_length', hover_data=['petal_width'],color_discrete_map=color)
#------------------------------------ fake legend -------------------------------------------------------
fig.add_shape(type="rect",
xref="paper", yref="paper",
x0=.46, y0=1.17,
x1=.47, y1=1.12,
line=dict(
color="lightsalmon",
# width=3,
),
fillcolor="lightsalmon",
)
fig.add_shape(type="rect",
xref="paper", yref="paper",
x0=.56, y0=1.17,
x1=.57, y1=1.12,
line=dict(
color="lightseagreen",
# width=3,
),
fillcolor="lightseagreen",
)
fig.add_shape(type="rect",
xref="paper", yref="paper",
x0=.67, y0=1.17,
x1=.68, y1=1.12,
line=dict(
color="royalblue",
# width=3,
),
fillcolor="royalblue",
)
annotations = []
annotations.append(dict(xref='paper', yref='paper',
x=.5, y=1.2,
text='setosa',
font=dict(family='garamond', size=20,),
showarrow=False))
annotations.append(dict(xref='paper', yref='paper',
x=.615, y=1.2,
text='versicolor',
font=dict(family='garamond', size=20,),
showarrow=False))
annotations.append(dict(xref='paper', yref='paper',
x=.75, y=1.2,
text='virginica',
font=dict(family='garamond', size=20,),
showarrow=False))
fig.update_layout(annotations=annotations)
fig