Skip to content

Instantly share code, notes, and snippets.

@debonx
Last active August 21, 2019 10:21
Show Gist options
  • Save debonx/ada2caf0cd0fe2479d6b4d2af0a531c1 to your computer and use it in GitHub Desktop.
Save debonx/ada2caf0cd0fe2479d6b4d2af0a531c1 to your computer and use it in GitHub Desktop.
Example of using Matplotlib library to display data on graphs. More at https://matplotlib.org/.
from matplotlib import pyplot as plt
#Set data to display > [lists]
x = [1,7,5,2]
y1 = [5,6,3,9]
y2 = [7,8,4,0]
#Create plots with line colors and marker style
plt.plot(x, y1, color="pink", marker="o")
plt.plot(x, y2, color="gray", marker="o")
#Assign title, labels and legend
plt.title("Two Lines on One Graph")
plt.xlabel("Amazing X-axis")
plt.ylabel("Incredible Y-axis")
plt.legend(["x label", "y1 label", "y2 label"])
#Show Plot
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment