Locked lesson.
About this lesson
Let's create line plots and discuss some of the options you can use to change their appearance.
Exercise files
Download this lesson’s related exercise files.
Plotting Line Plots.docx57.1 KB Plotting Line Plots - Solution.docx
55.4 KB
Quick reference
Plotting Line Plots
Line plots can be created using two methods.
When to use
Use these methods whenever you want to create a line plot.
Instructions
The first method to create a line plot is:
my_df.plot(kind='line')
We can change the chart size with the figsize flag:
my_df.plot(kind='line', figsize=(10,5))
We can change the thickness of the line with the lw flag:
my_df.plot(kind='line', alpha=0.4, figsize=(10,5), lw=4)
To plot a specific column:
my_df['Mon'].plot(kind='line', alpha=0.4, figsize=(10,5))
To plot multiple columns:
my_df[['Mon', 'Tues']].plot(kind='line', alpha=0.4, figsize=(10,5), lw=5)
The second method to create a line plot is:
my_df.plot.line()
Hints & tips
- my_df.plot(kind='line', alpha=0.4, figsize=(10,5), lw=4)
- my_df.plot.line()
Lesson notes are only available for subscribers.