Python Line Charts

Customizing the x and y labels are a simple way to make the graph more notable, and these filters share much in common with other customizations in the chart:

Code:

import pandas as pd

df = pd.read_excel('world_population_growth.xlsx')

df.plot( 'Year' , 'Population' )

plt.xlabel('Year', fontweight='bold', color = 'orange', fontsize='17', horizontalalignment='center', rotation=45)

plt.ylabel('Population (billions)', fontweight='bold', color = 'orange', fontsize='17', horizontalalignment='center')

Explanation:

  • fontweight is similar to Word’s bold

  • color can be anything you’d like from here (https://matplotlib.org/stable/gallery/color/named_colors.html)

  • fontsize can be adjusted however you like

  • horizontalalignment is the placement of the label

  • rotation is how much you’d like the text shifted, if it was 90 then the x label would be in the same format as the default y label positioning

  • Add a short summary or a list of helpful resources here.