Posts

Showing posts from September, 2024

Making boxplot with custom statistical values for the boxes

Image
We will see here how to draw boxplots, using Matplotlib, when we have a set of values that represent the box statistics, such as median, mean, minimum, maximum, first quartile, and third quartile. In some case we may also have confidence interval of the median values. We will use the .bxp attribute of the plot axes in pyplot.subplots . We begin first by importing the necessary packages to draw the boxplots, namely, NumPy and Matplotlib . import numpy as np import matplotlib.pyplot as plt The data Let’s take an example of a data. Show in the table below is the data which can be read from a excel or csv file into a pandas dataframe ( df ). df label whislo q1 med mean q3 whishi cilo cihi 0 A 8 26 56 49 96 116 54 62 1 B 7 21 53 45 96 122 51 59 2 C 10 22 57 54 101 120 55 63 3 D 9 26 54 50 98 116 52 60 Convert data into list of dictionaries For making the plot...