How to hide legend with Plotly Express and Plotly in Python? Last Updated : 19 Dec, 2021 Comments Improve Suggest changes 1 Likes Like Report 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. Python3 # importing packages import plotly.express as px # using the gapminder dataset df = px.data.tips() fig = px.scatter(df, x="total_bill", y="tip", color="sex", symbol="smoker", facet_col="time", labels={"sex": "Gender", "smoker": "Smokes"}) # hiding legend in pyplot express. fig.update_traces(showlegend=False) fig.show() Output: 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. Python3 import plotly.graph_objects as go # using the Figure dataset fig = go.Figure() fig.add_trace(go.Line(name="first", x=["a", "b"], y=[1,3])) fig.add_trace(go.Line(name="second", x=["a", "b"], y=[2,1])) fig.add_trace(go.Line(name="third", x=["a", "b"], y=[1,2])) fig.add_trace(go.Line(name="fourth", x=["a", "b"], y=[2,3])) # hiding legend in pyplot express. fig.update(layout_showlegend=False) fig.show() Output: 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. Python3 import plotly.express as px # using the iris dataset df = px.data.iris() # plotting the line chart fig = px.line(df, y="sepal_width", line_dash='species', color='species') # hiding legend in pyplot express. fig.update_traces(showlegend=False) # showing the plot fig.show() Output: Comment S skrg141 Follow 1 Improve S skrg141 Follow 1 Improve Article Tags : Python Python-Plotly Python Plotly express-class Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like