Last active
January 16, 2020 23:38
-
-
Save Ze1598/217f18b7a4f143bf5de68a5c208569aa to your computer and use it in GitHub Desktop.
Matplotlib intro: line plots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from matplotlib import pyplot as plt | |
| nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
| doubles = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] | |
| squares = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] | |
| plt.plot(nums, doubles, label="Doubles", color="red") | |
| plt.plot(nums, squares, label="Squares", color="blue") | |
| plt.xlabel("Number") | |
| plt.ylabel("Result") | |
| plt.title("Evolution of doubles and squares for the range [1,10]") | |
| plt.legend() | |
| plt.tight_layout() | |
| plt.savefig("line_plot_demo.png") | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment