Complete the code to create a violin plot of the data list.
import matplotlib.pyplot as plt data = [1, 2, 3, 4, 5, 6, 7] plt.[1](data) plt.show()
The plt.violinplot() function creates a violin plot, which shows the distribution of the data.
Complete the code to add a title to the violin plot.
import matplotlib.pyplot as plt data = [5, 10, 15, 20, 25] plt.violinplot(data) plt.[1]('My Violin Plot') plt.show()
The plt.title() function adds a title to the plot.
Fix the error in the code to correctly plot multiple violin plots for two data sets.
import matplotlib.pyplot as plt data1 = [1, 2, 3, 4, 5] data2 = [2, 3, 4, 5, 6] plt.violinplot([1]) plt.show()
To plot multiple violin plots, the data must be passed as a list of lists, like [data1, data2].
Fill both blanks to create a violin plot with custom positions and show the plot.
import matplotlib.pyplot as plt data = [[1, 2, 3], [4, 5, 6]] plt.violinplot(data, positions=[1]) plt.[2]()
The positions argument sets where the violins appear on the x-axis. plt.show() displays the plot.
Fill all three blanks to create a violin plot with custom widths, show means, and display the plot.
import matplotlib.pyplot as plt data = [3, 5, 7, 9, 11] plt.violinplot(data, widths=[1], showmeans=[2]) plt.[3]()
The widths argument controls the width of the violin plot. showmeans=True shows the mean marker. plt.show() displays the plot.