import matplotlib.pyplot as plt measures = [-1.2, 1.2, -5.3, -9.9, 0.7, -7.5, 0.4, 2.8, 2.7, 4.8, 1.3, 1.1, 6.6, 4.2, 5.8, 6.5, 2.4, 3.4, 5.9, 2.4, -0.9, -1.5, 4.1, 8.3, 7.9, 9.2, 9.9, 6.0] old_values = [1.3, 5, 6, -2.1, 3.1, 2, 1.9, -5] # Draw a boxplot from statistics in the list measures: # plt.boxplot(measures) # boxplot # plt.show() # the small circles are outliers # Two boxplots in one window: data = [measures, old_values] fig, ax1 = plt.subplots() # fig for saving the image ax1.set_title('Basic Plot') ax1.set_xticklabels(['2021','1998']) ax1.grid() # gives only horizontal lines, since no numbers on x-axis # annotate: xy: where the interesting thing is, xytext= place the text here. plt.annotate('Current values', xy=(1,10), xytext=(0.8, 10)) plt.annotate('Old values', xy=(1, 10), xytext=(1.9, 10)) plt.annotate('Outlier', xy=(1, -7.5), xytext=(1.4, 0), arrowprops=dict(facecolor='red')) plt.boxplot(data) fig.savefig("7_2.png") # Save the image plt.show()