Skip to content

Instantly share code, notes, and snippets.

@Ze1598
Created January 15, 2020 19:46
Show Gist options
  • Save Ze1598/93a0fa1b0c821e8a8418ab9d86bbd5e0 to your computer and use it in GitHub Desktop.
Save Ze1598/93a0fa1b0c821e8a8418ab9d86bbd5e0 to your computer and use it in GitHub Desktop.
Matplotlib intro: scatter plots
from matplotlib import pyplot as plt
x_coords = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
fav_nums = [9, 37, 45, 32, 46, 56, 28, 9, 16, 68, 64, 100, 25, 1, 59, 50, 31, 96, 13, 76]
plt.scatter(x_coords, fav_nums, marker="x", color="red")
plt.ylabel("Favorite number")
plt.xticks([])
plt.title("Favorite number of twenty individuals")
plt.tight_layout()
plt.savefig("scatter_plot_demo.png")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment