Graphing Charts in Python
Python Line Charts
Legends are especially useful when dealing with multiple time series in a chart — here’s how to move the default legend to the bottom right:
Code:
import pandas as pd
df = pd.read_excel('world_population_growth.xlsx')
df.plot( 'Year' , 'Population' )
plt.xlabel('Year')
plt.ylabel('Population (billions)')
plt.title('World Population Growth By Year', fontsize=18, color="blue", pad = 10, loc="left", fontstyle='italic')
plt.legend(loc="lower right")
Explanation:
Loc specifies where in the chart you’d like to place the legend, and the visual customizations we’ve added in the title and x and y labels in previous lessons are also available too.
-
Add a short summary or a list of helpful resources here.