如何为distplots的每个子图添加注释?

时间:2019-08-18 17:32:48

标签: python matplotlib annotations jupyter-notebook subplot

我试图将每个子图标记为“正偏”或“负偏”,具体取决于这些散点图显示的偏度。我使用过matplotlib和seaborn作为涉及的软件包。如何通过以下方式注释或标记这些图形?

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

1 个答案:

答案 0 :(得分:0)

您可以使用Axes.text,或使用功能更强大的Axes.annotate

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