Plotly - How to show legend in single-trace scatterplot with plotly express? Last Updated : 28 Feb, 2022 Comments Improve Suggest changes Like Article Like Report In this article let's see how to show legend in single-trace scatterplot with plotly express. A 'trace' is the name given to each plot inside the chart. Generally in plotly legend is not visible for single trace scatter plots. Example: In the below, example packages and data are imported and a single trace scatter plot is plotted using px.scatter(). fig.layout.showlegend= True doesn't work in this case so we need to enable showlegend by using this code fig['data'][0]['showlegend']=True. fig['data'][0]['name']='Humidity' says that name of the only variable in the legend is 'Humidity'. To view and download the CSV file used click here. Python3 # import packages and libraries import pandas as pd from matplotlib import pyplot as plt import numpy as np import plotly.express as px # reading the dataset df = pd.read_csv('weather.csv', encoding='UTF-8') # creating a scatterplot fig = px.scatter(df, x="Temperature", y='Humidity', trendline='ols', trendline_color_override='red') fig['data'][0]['showlegend'] = True fig['data'][0]['name'] = 'Humidity' fig.show() Output: Before setting legend After setting legend. Comment More infoAdvertise with us Next Article Plotly - How to show legend in single-trace scatterplot with plotly express? I isitapol2002 Follow Improve Article Tags : Python Geeks Premier League Geeks-Premier-League-2022 Python-Plotly Practice Tags : python Similar Reads How to hide legend with Plotly Express and Plotly in Python? 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( 2 min read How to Connect Scatterplot Points With Line in Matplotlib? Prerequisite: Scatterplot using Seaborn in Python Scatterplot can be used with several semantic groupings which can help to understand well in a graph. They can plot two-dimensional graphics that can be enhanced by mapping up to three additional variables while using the semantics of hue, size, and 2 min read How to add a legend to a scatter plot in Matplotlib ? Adding a legend to a scatter plot in Matplotlib means providing clear labels that describe what each group of points represents. For example, if your scatter plot shows two datasets, adding a legend will display labels for each dataset, helping viewers interpret the plot correctly. We will explore s 2 min read How To Place Legend Outside the Plot with Seaborn in Python? Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. Basically, it helps us stylize our basic plot made using matplotlib. Moreover, it also provides us different plotting techniques to ease 2 min read Hide legend in plotly express in Python? In this article, we will discuss how to hide legend in plotly express using Python. Dataset in use: bestsellers4 The legend appears by default when variation in one object has to be depicted with reference to the other. Legend makes it easier to read a graph since it contains descriptions for the co 1 min read Like