Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

position of legend matplotlib

plt.legend(loc='upper right')
Comment

place legend on location matplotlib

import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = 6, 3
fig, axes = plt.subplots(ncols=3)
locs = ["upper left", "lower left", "center right"]
for l, ax in zip(locs, axes.flatten()):
    ax.set_title(l)
    ax.plot([1,2,3],[2,3,1], "b-", label="blue")
    ax.plot([1,2,3],[1,2,1], "r-", label="red")
    ax.legend(loc=l, bbox_to_anchor=(0.6,0.5)) # This is the key statement. 
    ax.scatter((0.6),(0.5), s=81, c="limegreen", transform=ax.transAxes)

plt.tight_layout()    
plt.show()
Comment

matplotlib location legend

plt.legend(loc='best')
plt.legend(loc='upper right')
plt.legend(loc='Center left')
plt.legend(loc='Upper center')
# etc.
Comment

matplotlib legend location manual

answer=this is how we are defining the location of legend
Comment

PREVIOUS NEXT
Code Example
Python :: how to use enumerate in python 
Python :: how to remove a string inside another string python 
Python :: convert a pdf folder to excell pandas 
Python :: execute linux command in python 
Python :: plt.annotate text size 
Python :: python ftplib get list of directories 
Python :: pandas replace values based on condition 
Python :: Delete file in python Using the os module 
Python :: python vs c++ 
Python :: how to use csv in python 
Python :: urllib.request.urlretrieve 
Python :: contains duplicate in python 
Python :: how to check libraries in python 
Python :: find sum of 2 numbers in array using python 
Python :: python package version in cmd 
Python :: tasks discord py 
Python :: how to import request library in python 
Python :: python random liste 
Python :: drop rows from dataframe based on column value 
Python :: django include all columns admin show 
Python :: python fillna with mean in a dataframe 
Python :: xgboosat save_model 
Python :: convert numpy array to cv2 image 
Python :: count a newline in string python 
Python :: python lambda function map 
Python :: python retry 
Python :: django save image 
Python :: python break for loop 
Python :: python elasticsearch put index 
Python :: django static files 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =