Plot or chart is simply a visual representation of numeric data. You will have access to a huge number of statistical plt types. You can see the gallery of what kind of graph that MatPlotLib can make here.
We will use the hurricane.csv throughout this section. The file shows simple table of year and month of the year which contains the number of hurricane happening in each month.
Plot show graphically what you've defined numerically. To define a plot, you need matplotlib.pyplot module.
Let's try to plot the number of hurricane in 2005.(You can easily save the .png by clicking the arrow next to trinket_plot.png)
The first argument in plot shows the x-axis: value (5,13) shows the month number 5 (May) until 12 (December).You encounter many situations in which you must use multiple plot lines, such as when comparing two sets of values. To do that, you simply call plt.plot() multiple times. You will see multiple plot lines with different colors.
Let's try to plot the number of hurricane in 2005 and 2015.
Note that instead of number, we want the x-axis to be the names of the months. You can use .xticks for this. Note that we need to flatten the DataFrame into a list using .flatten().
To further change the axes, we need to assign a variable for axes, here we use ax. There are many things we can do with that, like showing grid using .grid()
Line styles help differentiate the graphs. Here are the character representing the line styles:
We try to change the grid to dotted lines, 2005 into solid line, and 2015 into dashed line.
Color is another way to differentiate line graphs The following list shows the color that MatPlotLib supports
Markers add a special symbol to each data point in a line graph. The following list shows some of markers:
The airtravel.csv contains monthly transatlantic airtravel, in thousands of passengers. Plot the flight in 1958 and 1960.
Also, configure the axis, color, and markers so it looks exactly like the plot below.