1

I have a scatteplot I’m trying to present, with lots of symbols and colors. This makes the default legend unreadable. Is there a way to hide the legend (equivalent, or similar to showlegend=False when using traces and graph objects)?

Here’s my graphing line:

fig = px.scatter(df_revised, x='df_x', y = 'df_y', color = 'type', symbol = 'country', hover_data = ['id'], marginal_y="histogram", marginal_x="histogram")

I've seen the question mentioned here, but that is not useful, as it's changing the plotting library to plotly rather that the express version.

I have also tried fig.update_layout(showlegend=False) but that return an error AttributeError: 'ExpressFigure' object has no attribute 'update_layout'

guyts
  • 899
  • 2
  • 17
  • 34
  • 2
    If you’re seeing that error you’re using an older version of Plotly/Plotly Express... upgrading to the latest version will enable this pattern :) – nicolaskruchten Aug 21 '19 at 14:11
  • 1
    Also please note: Plotly Express is now part of Plotly and has always used it internally, so there’s no real distinction between the two :) – nicolaskruchten Aug 21 '19 at 14:13

1 Answers1

2

With the version you have right now, fig.layout.showlegend = False should work (and continues to work with the latest version!).

nicolaskruchten
  • 26,384
  • 8
  • 83
  • 101