10 a] Describe the process of creating a box plot in Matplotlib. with suitable programming example.
Box Plot
The box plot shows multiple statistical measurements. The box extends from the lower to the upper quartile values of the data, thereby allowing us to visualize the interquartile range. For more details regarding the plot, refer to the previous chapter. The plt.boxplot(x) function creates a box plot.
Important parameters:
- x: Specifies the input data. It specifies either a 1D array for a single box, or a sequence of arrays for multiple boxes.
- notch: (optional) If true, notches will be added to the plot to indicate the confidence interval around the median.
- labels: (optional) Specifies the labels as a sequence.
- showfliers: (optional) By default, it is true, and outliers are plotted beyond the caps.
- showmeans: (optional) If true, arithmetic means are shown
Example:
plt.boxplot([x1, x2], labels=['A', 'B'])