The plot method of pandas

Our goal was to visualize all three series on the same plot (sharing the x-axis) to enable a quick visual comparison. To achieve this, we had to complete the following steps:

  • We created a subplot, which we then populated with individual plots. We specified that we wanted three plots vertically (by indicating plt.subplots(3, 1)). We also specified the figure size by setting the figsize parameter.
  • We added the individual plots using the plot method on a single Series (column) and specifying the axis on which we wanted to place the plot.
  • We used the set method to specify the title and axis labels on each of the plots.
When working in Jupyter Notebook, best practice is to run the %matplotlib inline magic (once per kernel) in order to display the plots directly below the code cell that has produced it. Additionally, if you are working on a MacBook with a Retina screen, running the extra IPython magic %config InlineBackend.figure_format ='retina' will double the resolution of the plots we make. Definitely worth the extra line!
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.82.163