如何为 distplots 的每个子图提供注释?
How can I give annotations to each subplot of distplots?
我试图根据这些 distplots 显示的偏度将我的每个子图标记为 "positively skewed" 或 "negatively skewed"。我使用了 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
您可以使用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")
我试图根据这些 distplots 显示的偏度将我的每个子图标记为 "positively skewed" 或 "negatively skewed"。我使用了 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
您可以使用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")