VOOZH about

URL: https://www.geeksforgeeks.org/python/how-to-hide-legend-with-plotly-express-and-plotly-in-python/

⇱ How to hide legend with Plotly Express and Plotly in Python? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to hide legend with Plotly Express and Plotly in Python?

Last Updated : 19 Dec, 2021

In this article, we will learn How to hide legend with Plotly Express and Plotly. Here we will discuss two different methods for hiding legend in plotly and plotly express, using two different examples for each to make it more clear.

Syntax: For legend:

  • fig.update_traces(showlegend=False)
  • fig.update(layout_showlegend=False)

Example 1:

In this example, we are hiding legend in Plotly Express with the help of method fig.update_traces(showlegend=False), bypassing the show legend parameter as False.

Output:

👁 Image
👁 Image

Example 2:

In this example, we are hiding legend in Plotly with the help of method fig.update(layout_showlegend=False), by passing the showlegend parameter as False.

Output:

👁 Image
👁 Image

Example 3:

In this example, we are hiding legend in Plotly Express with the help of method fig.update_traces(showlegend=False), by passing the layout_showlegend parameter as False.

Comment