Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to add legend to python plot

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

PREVIOUS NEXT
Code Example
Python :: copy text to clipboard python 
Python :: how to talk to girls 
Python :: selenium press tab python 
Python :: numpy print full array 
Python :: python saving a screentshot with PIL 
Python :: select first word in string python 
Python :: import apiview 
Python :: running selenium on google colab 
Python :: accuracy score sklearn syntax 
Python :: use incognito in selenium webdriver 
Python :: how to import pygame onto python 
Python :: conditional row delete pandas 
Python :: plot image without axes python 
Python :: add picture to jupyter notebook 
Python :: python dlete folder 
Python :: convert python list to text file 
Python :: get python directiory 
Python :: how to convert list into csv in python 
Python :: python resize image 
Python :: python regex flags 
Python :: turn list to string with commas python 
Python :: python read csv into array 
Python :: convert column string to int pandas 
Python :: sort python nested list according to a value 
Python :: decimal places django template 
Python :: python how to flatten a list 
Python :: pandas add suffix to column names 
Python :: enter key press bind tkinter 
Python :: what is self in programming 
Python :: print json python 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =