【发布时间】:2019-03-20 21:06:49
【问题描述】:
import matplotlib.patches as patches
df2 = pd.melt(
data2.query('worktype_id!=38')[['period','worktype', 'utilization_billable', 'utilization' ]],
id_vars=['period', 'worktype']).sort_values(['period', 'variable'], ascending=[True, True])
g = sns.relplot(x='period', y='value',
hue='variable', data=df2, col='worktype', kind='line', col_wrap=4,
)
for ax in g.axes:
ax.axhline(y=75, color='g', linestyle='--')
ax.axhline(y=90, color='r', linestyle='--')
rect = plt.Rectangle((10,10),10,10,linewidth=3,edgecolor='r',facecolor='red', alpha=1)
ax.add_patch(rect)
我想在 y=75 和 90 之间绘制方框(图表上的绿线和红线),但是当我执行 ax.add_patch
时没有显示任何内容这是我得到的图像:
那么我如何填充红色和绿色水平线之间的区域?
【问题讨论】:
标签: python pandas matplotlib