Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python plot two lines on same graph

import matplotlib.pylot as plt
x_coordinates = [1, 2, 3]

y1_coordinates = [1, 2, 3]
y2_coordinates = [3, 4, 5]

fig = plt.figure(1)
plt.plot(x_coordinates, y1_coordinates) # plot first line
plt.plot(x_coordinates, y2_coordinates) # plot second line
plt.show()
Comment

python plot multiple lines in same figure

# Short answer:
Call plt.plot() as many times as needed to add additional lines to plot.

# Example usage:
import matplotlib.pylot as plt
x_coordinates = [1, 2, 3]

y1_coordinates = [1, 2, 3]
y2_coordinates = [3, 4, 5]

plt.plot(x_coordinates, y1_coordinates) # plot first line
plt.plot(x_coordinates, y2_coordinates) # plot second line
Comment

PREVIOUS NEXT
Code Example
Python :: seaborn set title 
Python :: how to square each term of numpy array python 
Python :: read image python 
Python :: rename the console python 
Python :: pip install ffmpeg 
Python :: python read dictionary from file 
Python :: how to check if an element is visible on the web page in selenium python 
Python :: print whole dataframe python 
Python :: get object attributes python 
Python :: pca python 
Python :: extract numbers from sklearn classification_report 
Python :: how to read a json resposnse from a link in python 
Python :: .get python 
Python :: no module named pyplot 
Python :: f string float format 
Python :: extract name organization using nltk 
Python :: read txt in pandas 
Python :: np.random.seed 
Python :: discord command addrole python 
Python :: snowflake python connector error handling 
Python :: Need Clang = 7 to compile Filament from source 
Python :: resample and replace with mean in python 
Python :: get current file location 
Python :: how to openn file dialog in tkinter 
Python :: start the environment 
Python :: multiple loss pytorch 
Python :: insert QlineEdit into QMenu python 
Python :: minimum from list of tuples 
Python :: replace space with _ in pandas 
Python :: label encoder pyspark 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =