Black Lives Matter. Please consider donating to Black Girls Code today.
https://www.blackgirlscode.com

How to Remove 'Aa' from the Legend

How to remove ‘Aa’ from the legend while still keeping the text in the markers??

The code below is from the example on this page under Adding Text to Data in Line and Scatter Plots: https://plotly.com/python/text-and-annotations/

import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(go.Scatter(
    x=[0, 1, 2],
    y=[1, 1, 1],
    mode="lines+markers+text",
    name="Lines, Markers and Text",
    text=["Text A", "Text B", "Text C"],
    textposition="top center"
))

fig.add_trace(go.Scatter(
    x=[0, 1, 2],
    y=[2, 2, 2],
    mode="markers+text",
    name="Markers and Text",
    text=["Text D", "Text E", "Text F"],
    textposition="bottom center"
))

fig.add_trace(go.Scatter(
    x=[0, 1, 2],
    y=[3, 3, 3],
    mode="lines+text",
    name="Lines and Text",
    text=["Text G", "Text H", "Text I"],
    textposition="bottom center"
))

fig.show()

Thanks

Hi @Muto, welcome to the forum! I’m afraid it’s not possible at the moment, the ‘Aa’ is hardcoded in the legend when the trace has a text argument. You can open a feature request issue in the plotly.js about this.

One alternative is to have two traces: one for markers and one for text, then hide the legend entry for the text one and have it be in the same legend group as the marker one.

1 Like