Boxplots and Histograms
Boxplots represent a graphical rendition of the minimum, median, quartiles, and maximum of your data. You can generate a boxplot by calling the .boxplot()
method on a DataFrame.
Another method to produce visual summaries is by leveraging histograms, which allow you to inspect the data and uncover its underlying distribution, as well as the presence of outliers and overall spread. An example of how to generate a histogram is shown below:
ax = co2_levels.plot(kind='hist', bins=100)
Here, we used the standard .plot()
method but specified the kind
argument to be 'hist'
. In addition, we also added the bins=100
parameter, which specifies how many intervals (i.e bins
) we should cut our data into.
Cet exercice fait partie du cours
Visualizing Time Series Data in Python
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Generate a boxplot
ax = ____.____
# Set the labels and display the plot
ax.set_xlabel('CO2', fontsize=10)
ax.set_ylabel('Boxplot CO2 levels in Maui Hawaii', fontsize=10)
plt.legend(fontsize=10)
plt.show()