Hide legend entries in a plotly figure
You can set any parameters of figure before plotting like here:
import pandas as pd
import plotly.offline as py
import plotly.graph_objs as go
import cufflinks as cf
cf.go_offline()
df = pd.DataFrame(data=[[0, 1, 2], [3, 4, 5]], columns=['A', 'B', 'C'])
# get figure property
fig = df.iplot(kind='scatter', asFigure=True)
# set showlegend property by name of trace
for trace in fig['data']:
if(trace['name'] != 'B'): trace['showlegend'] = False
# generate webpage
py.plot(fig)
Not sure if this is a recent addition, but in current versions of plotly (4.0 and above), you can do fig.update(layout_showlegend=False)
.