Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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

position of legend matplotlib

plt.legend(loc='upper right')
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

legend matplotlib


import matplotlib.pyplot as plt

#define x and ysin
plt.plot(x,ysin,label='sin(x)')
plt.legend()
plt.show()
Comment

legend ax matplotlib

ax.plot([1, 2, 3], label='Inline label')
ax.legend()
Comment

PREVIOUS NEXT
Code Example
Python :: check django version 
Python :: scikit learn svm 
Python :: remove last element from dictionary python 
Python :: clear all python cache 
Python :: python import ndjson data 
Python :: python check if input is between two values 
Python :: python exe not working on other pc 
Python :: 13 digit timestamp python 
Python :: pandas read chunk of csv 
Python :: python break when key pressed 
Python :: python iterate over multidimensional dictionary 
Python :: python shuffle list with seed 
Python :: python pandas dataframe from csv index column 
Python :: polyfit python 
Python :: all subarrays of an array python 
Python :: pygame.key.get_pressed() 
Python :: the system cannot find the file specified sublime text 3 python 
Python :: python writeline file 
Python :: django phone number field 
Python :: reset a turtle python 
Python :: connect flask with postgresql 
Python :: pandas get date from datetime 
Python :: how to input 2-d array in python 
Python :: media django 
Python :: decode html python 
Python :: count items in list 
Python :: django dumpdata 
Python :: instagram private account hacking code python 
Python :: python create virtualenv 
Python :: how to click on button using python 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =