Closed Ripper1111 closed 2 months ago
Hello @Ripper1111!
To achieve the behavior you are describing, you simply need to set the name
attribute of your traces equal to an empty string, like this:
import plotly.express as px
import plotly.graph_objs as go
fig = go.Figure()
fig.add_trace(go.Scatter( x=[1, 2, 3, 4, 5], y=[1, 2, 3, 4, 5], name="" ))
fig.add_trace(go.Scatter( x=[1, 2, 3, 4, 5], y=[5, 4, 3, 2, 1], name="" ))
fig.show()
It is important to note that the showlegend
attribute does not impact hover labels- it is used to toggle the visibility of legend in the top right of the figure.
To learn more about formatting hover labels, you can check out this documentation page: https://plotly.com/python/hover-text-and-formatting/
Hope that helps!
Thank You it solved the markers issue.
But now I observed that when I applyed the code on candlestick chart the candlestick is also give the same legend at the label. Without add_trace
it shows no trace0
# set the data from our data frame
data=[go.Candlestick(x=df_symbol_bar_Data['datetime'],
open=df_symbol_bar_Data['open'],
high=df_symbol_bar_Data['high'],
low=df_symbol_bar_Data['low'],
close=df_symbol_bar_Data['close'],
showlegend=False)]
# display the Candlestic chart with the optional layout
figSignal = go.Figure(data=data,layout=layout)
figSignal.add_trace(go.Scatter(
x=[high_time,low_time],
y=[high_px,low_px],
mode="markers+text",
name="",
text=["HIGH","LOW"],
textposition=["top center","bottom center"],
textfont=dict(
family="sans serif",
size=18,
color=["LightSeaGreen","Red"]
),
showlegend=False
))
figSignal.update_traces(showlegend=False)
Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson
Hi How to remove the legend on the back of the marker? Whenever I hover mouse over the market it gives trace0 legend even I used showlegend=False.
fig = go.Figure() fig.add_trace(go.Scatter( x=[1, 2, 3, 4, 5], y=[1, 2, 3, 4, 5], showlegend=False )) fig.add_trace(go.Scatter( x=[1, 2, 3, 4, 5], y=[5, 4, 3, 2, 1], )) fig.update_layout(showlegend=True) fig.show()