MulaiMulai sekarang secara gratis

Creating boxplots

Boxplots provide additional information about the distribution of the data that they represent. They tell us what the median of the distribution is, what the inter-quartile range is and also what the expected range of approximately 99% of the data should be. Outliers beyond this range are particularly highlighted.

In this exercise, you will use the data about medalist heights that you previously visualized as histograms, and as bar charts with error bars, and you will visualize it as boxplots.

Again, you will have the mens_rowing and mens_gymnastics DataFrames available to you, and both of these DataFrames have columns called "Height" that you will compare.

Latihan ini adalah bagian dari kursus

Introduction to Data Visualization with Matplotlib

Lihat Kursus

Petunjuk latihan

  • Create a boxplot that contains the "Height" column for mens_rowing on the left and mens_gymnastics on the right.
  • Add x-axis tick labels: "Rowing" and "Gymnastics".
  • Add a y-axis label: "Height (cm)".

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

fig, ax = plt.subplots()

# Add a boxplot for the "Height" column in the DataFrames
____

# Add x-axis tick labels:
____

# Add a y-axis label
____

plt.show()
Edit dan Jalankan Kode