Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

matplotlib legend out of plot

ax.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05),
          ncol=3, fancybox=True, shadow=True)
Comment

matplotlib legend

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 20, 1000)
y1 = np.sin(x)
y2 = np.cos(x)

plt.plot(x, y1, "-b", label="sine")
plt.plot(x, y2, "-r", label="cosine")
plt.legend(loc="upper left")
plt.ylim(-1.5, 2.0)
plt.show()
Comment

matplotlib position legend

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

matplotlib legend out of plot

ax.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05),
          ncol=3, fancybox=True, shadow=True)
Comment

matplotlib legend

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 20, 1000)
y1 = np.sin(x)
y2 = np.cos(x)

plt.plot(x, y1, "-b", label="sine")
plt.plot(x, y2, "-r", label="cosine")
plt.legend(loc="upper left")
plt.ylim(-1.5, 2.0)
plt.show()
Comment

matplotlib position legend

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

PREVIOUS NEXT
Code Example
Python :: how to sum digits of a number in python 
Python :: superscript print python 
Python :: how to save a model fast ai 
Python :: how to increase height of entry in tkinter 
Python :: python alfabet 
Python :: version of scikit learn 
Python :: marks input using list in python 
Python :: python for get index and value 
Python :: replace cell pandas 
Python :: train_test_split without shuffle 
Python :: python dockerfile 
Python :: python web3 to wei 
Python :: insert image to jupyter notebook 
Python :: python get int from string 
Python :: pandas remove index column when saving to csv 
Python :: python print os platform 
Python :: colab tqdm import 
Python :: python year month from date 
Python :: close turtle window python 
Python :: find elements by class name selenium python 
Python :: generate random characters in python 
Python :: django admin slug auto populate 
Python :: how do i print when my bot is ready in discord.py 
Python :: downgrade pip 
Python :: python generate random strong password 
Python :: python image read 
Python :: py check discord token 
Python :: get max pixel value python 
Python :: get ip from request django 
Python :: python decimal number into 8 bit binary 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =