plot ([2, 4, 6], label=" First Data ") plt. Your email address will not be published. bbox_to_anchor specifies the legend box’s location. By Sumanth Mahishi. Legend outside plot axes; Reorder labels in legend; Confused about pyplot and matplotlib? PyQtGraph - Getting Plot Item from Plot Window, Time Series Plot or Line plot with Pandas, Python | Remove all sublists outside the given range, Python | Using variable outside and inside the class and method. acknowledge that you have read and understood our, GATE CS Original Papers and Official Keys, ISRO CS Original Papers and Official Keys, ISRO CS Syllabus for Scientist/Engineer Exam, Adding new column to existing DataFrame in Pandas, Python program to convert a list to string, How to get column names in Pandas dataframe, Reading and Writing to text files in Python, isupper(), islower(), lower(), upper() in Python and their applications, Taking multiple inputs from user in Python, Python | Program to convert String to a List, Different ways to create Pandas Dataframe, Python | Split string into list of characters, Integration by Partial Fractions - Integrals. Fortunately, Matplotlib provides a simple API for manually placing legends, and it even supports placing legends outside the plot area altogether. One option is to put the legend outside of the axis, but we have multiple subplots here and that would be pretty difficult. code, Legends overlap the graph (incomplete information). 1.1. Experience. To start: import matplotlib.pyplot as … The following code shows how to place the legend in the top right corner outside of a Matplotlib plot: Note that the loc argument tells Matplotlib to place the upper left corner of the legend line at the (x,y) coordinates of (1,1) in the plot. Note that to set the default font size, one can change the legend.size property in the matplotlib rc parameters file. The first step I tried to move the legend outside the figure was to add this code to the “legend” method: plt.legend(loc='upper left', bbox_to_anchor=(1,1)) Unfortunately, the legend was being cut-off on … How to Align