plot two lines in python code example
Example 1: 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
Example 2: print multiple lines python
#You can use \n to create a carriage return.
print("first line\nSecond line")
#Or use the following syntax to replace the commas with \n
#to create carriage returns for each line.
print("first line", "second line", sep="\n")
#Or use triple quotation marks at the start and end of
#the text and format the text how you want it to appear.
print("""
Line1
Line2
""")