0
0
Matplotlibdata~10 mins

Box plot vs violin plot comparison in Matplotlib - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the matplotlib plotting library.

Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Anumpy
Bseaborn
Cpandas
Dmatplotlib.pyplot
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong library like seaborn or numpy.
Forgetting to use the alias plt.
2fill in blank
medium

Complete the code to create a box plot of the data list.

Matplotlib
plt.[1](data)
Drag options to blanks, or click blank then click option'
Ascatter
Bviolinplot
Cboxplot
Dhist
Attempts:
3 left
💡 Hint
Common Mistakes
Using violinplot instead of boxplot.
Using hist or scatter which are different plot types.
3fill in blank
hard

Fix the error in the code to create a violin plot of the data list.

Matplotlib
plt.[1](data)
Drag options to blanks, or click blank then click option'
Aviolinplot
Bboxplot
Cplot
Dbar
Attempts:
3 left
💡 Hint
Common Mistakes
Using boxplot instead of violinplot.
Using plot or bar which do not create violin plots.
4fill in blank
hard

Fill both blanks to create side-by-side box and violin plots for the same data.

Matplotlib
fig, ax = plt.subplots()
ax.[1](data, positions=[1])
ax.[2](data, positions=[2])
plt.show()
Drag options to blanks, or click blank then click option'
Aboxplot
Bscatter
Cviolinplot
Dhist
Attempts:
3 left
💡 Hint
Common Mistakes
Using scatter or hist instead of violinplot for the second plot.
Not specifying positions to separate the plots.
5fill in blank
hard

Fill all three blanks to create labeled box and violin plots with titles and axis labels.

Matplotlib
fig, ax = plt.subplots()
ax.[1](data, positions=[1])
ax.[2](data, positions=[2])
ax.set_xticks([1, 2])
ax.set_xticklabels([[3]])
ax.set_title('Box vs Violin Plot')
plt.show()
Drag options to blanks, or click blank then click option'
Aboxplot
Bviolinplot
C['Box Plot', 'Violin Plot']
D['Violin', 'Box']
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping boxplot and violinplot order.
Using wrong labels or mismatched labels for ticks.