Changing the location of Seaborn legends
We use matplotlib.pyplot.legend() function from matplotlib library and pass the bbox_to_anchor parameter which allows us to pass an (x,y) tuple with the required offset for changing the location of the seaborn legends.
Python3
# import modules import seaborn as sns import matplotlib.pylab as plt sns.set_style( "whitegrid" ) # load dataset tips = sns.load_dataset( "tips" ) # depict illustration fg = sns.stripplot(x = "sex" , y = "total_bill" , hue = "day" , data = tips, jitter = True ) # to change the legends location gfg.legend(bbox_to_anchor = ( 1.2 , 1 )) plt.show() |
Output:
How to change Seaborn legends font size, location and color?
Seaborn is a library for making statistical graphics on top of matplotlib with pandas data structures in python. Seaborn legend is the dialog box which is located on the graph which includes the description of the different attributes with their respected colors in the graph. We can easily change the properties of the seaborn legend including font size, location, background colour, and many others.
Here, We will learn about the way to change the font size, location, and the color of seaborn legend.
Contact Us