JavaScript
x
14
14
1
import matplotlib.patches as patches
2
3
df2 = pd.melt(
4
data2.query('worktype_id!=38')[['period','worktype', 'utilization_billable', 'utilization' ]],
5
id_vars=['period', 'worktype']).sort_values(['period', 'variable'], ascending=[True, True])
6
g = sns.relplot(x='period', y='value',
7
hue='variable', data=df2, col='worktype', kind='line', col_wrap=4,
8
)
9
for ax in g.axes:
10
ax.axhline(y=75, color='g', linestyle='--')
11
ax.axhline(y=90, color='r', linestyle='--')
12
rect = plt.Rectangle((10,10),10,10,linewidth=3,edgecolor='r',facecolor='red', alpha=1)
13
ax.add_patch(rect)
14
I want to draw the box between y=75 and 90 (green and red lines on the chart), but nothing is shown up when I do ax.add_patch
this is the image I get:
So How do I fill out the area between red and green horizontal lines?
Advertisement
Answer
If you have a fixed area you want to fill and you want to do it across the entire chart, you are probably better off using axvspan
. E.g.
JavaScript
1
2
1
ax.axvspan(75, 90, facecolor='red')
2