...

/

Plotting with a Series: Line, Bar, and Pie Plots

Plotting with a Series: Line, Bar, and Pie Plots

Explore how to create plots from series with pandas.

Line plots

For numeric time Series values we can plot a line plot:

Press + to interact
snow.plot.line()

A line plot in pandas plots the values in the series in the y-axis and the index in the x-axis. This plot is a little crowded as we are packing daily data for 40 years into the x-axis. We can slice off the last few years to zoom in on our resample to view trends. Here we pull off the last 300 values:

Press + to interact
snow.iloc[-300:].plot.line()

Note: By writing the code as above, we can easily remove the plot.line() and inspect the series that will be plotted.

Here let’s aggregate at the monthly level and look at the mean snowfall using resample with the 'M' offset alias and the ...