Intreoduction To Python Basic Plots With Matplolib
Intreoduction To Python Basic Plots With Matplolib
Matplotlib
I N TE R M E D I ATE P Y TH O N
Basic plots with Matplotlib
Visualization Data Structure
Report insights
1 Source: GapMinder, Wealth and Health of Nations
1 Source: GapMinder, Wealth and Health of Nations
1 Source: GapMinder, Wealth and Health of Nations
Matplotlib
import matplotlib.pyplot as plt
year = [1950, 1970, 1990, 2010]
help(plt.hist)
Choice depends on
Data
plt.plot(year, pop)
plt.show()
Axis labels
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.show()
Axis labels
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.show()
Title
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.show()
Title
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.show()
Ticks
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10])
plt.show()
Ticks
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10])
plt.show()
Ticks (2)
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
plt.show()
Ticks (2)
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
plt.show()
Add historical data
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
plt.show()
Add historical data
population.py
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
plt.show()
Before vs. after