I’m new to plotly and trying to make some plot using plotly.js. So I have this initial figure with a line and annotation. Now when the user press a button the data gets updated with restyle command. Now I want the annotation removed from the updated plot. How do I do that?
Hello,
It is helpful to include a snippet or link of your code while posting for a query as it aids the contributer resolve the problem more efficiently.
However, you can include ‘text’ and ‘texthover’ in your first plot and not include them in the second plot.
trace0 = go.Bar(
x=[1, 2, 3, 5.5, 10],
y=[10, 8, 6, 4, 2],
width = [0.8, 0.8, 0.8, 3.5, 4],
text = ["Web","Voicemail", "Phone", "Emails", "Walkup"],
textposition='top right',
textfont=dict(
family='sans serif',
size=18,
color='#1f77b4'
)
)
trace1=go.Bar(
x=[20, 18, 13, 11, 10],
y=[10, 8, 6, 4, 2]
)
data=[trace0, trace1]
This happens because annotations are applied to the entire layout of the plot, which includes all the plots as opposed to ‘text’ which is assigned within the required trace.
Hope this helped!
It doesn’t work the the text just stays there even after the restyle.