Search code examples
pythonmatplotlibannotationsjupyter-notebooksubplot

How can I give annotations to each subplot of distplots?


I'm trying to label each of my subplots as "positively skewed" or "negatively skewed" depending on the skewness shown by these distplots. I have used matplotlib and seaborn as packages involved. How can I annotate or label these graphs the following way ?

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sb
fig, ax = plt.subplots(1, 3, figsize=(18, 6))
sb.distplot(data['1_Yr_Return'], ax=ax[0], color='red')
sb.distplot(data['3_Yr_Return'], ax=ax[1], color='black')
sb.distplot(data['5_Yr_Return'], ax=ax[2], color='deepskyblue')
plt.rcParams['font.size'] = 12

enter image description here


Solution

  • You can use Axes.text, or the slightly more versatile Axes.annotate

    fig, ax = plt.subplots(1, 3, figsize=(10,5))
    ax[0].text(0.5,0.85,"Positively skewed")