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

plt.legend(

plt.legend(['first', 'second']);
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 :: random python between 0 and 1 
Python :: remove space characters from string in python 
Python :: user defined functions python 
Python :: python f string 2 decimals 
Python :: view all columns pandas 
Python :: how to square root in python 
Python :: Exit code: ENOENT. spawn /usr/bin/python ENOENT 
Python :: python - calculate the value range on a df 
Python :: python download complete web page 
Python :: Matplotlib rotated xticklabels 
Python :: group by, aggregate multiple column -pandas 
Python :: how to find the speed of a python program 
Python :: pil.jpegimageplugin.jpegimagefile to image 
Python :: python check if list 
Python :: python async partial function 
Python :: pycountry 
Python :: turn characters to alpgabetic numper python 
Python :: delete from list python 
Python :: smtplib send caleneder email 
Python :: django password field 
Python :: python tqdm 
Python :: pass context data with templateview in django 
Python :: replace list 
Python :: numpy method to make polynomial model 
Python :: making gifs via python 
Python :: python numpy array 
Python :: how to create dictionary in python from csv 
Python :: extract all text from website using beautifulsoup and python 
Python :: month name in python 
Python :: how to use random tree in python 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =