MatPlotLib! The Dreaded Line Graph...
Matplotlib is the default library to create charts for data analysis with Python. It works pretty well, and I get the satisfaction of learning how to use the code set I watched all my friends in college swear at for multiple years. Neat!
from matplotlib import pyplot as plt
# sample data
days = [0, 1, 2, 3, 4, 5, 6]
money_spent = [10, 12, 12, 10, 14, 22, 24]
plt.plot(days, money_spent)
plt.show()

These are pretty basic examples, and don't show off the strength of being able to generate a chart with a couple hundred points of data very quickly. This library can chew what Excel chokes on -- nothing is worse than sending over a good chart and finding out the CFO with a 4GB Surface Pro has no idea what chart you're talking about.
Charting with Style
Matplotlib can get much fancier. Below are charts demonstrating some bells and whistles, and a more complete list can be found in the docs, linked here



Generally Useful Things
To save a figure, use
plt.figure(figsize=(3,3))andplt.savefig('example_name.png')To remove all figures, use
plt.close('all')
Last updated
Was this helpful?