0

I have two line charts representing rates over time. I would like to use the fill_between function but can only seem to get a solid monotone color between my two lines. I think having a gradient shading would enhance the visual but could not find anything in the documentation to suggest that that is an option. Is there anyway to have a darker shade as my two line diverge and a lighter shade as they converge?

Below is my code:

x2=df2['Year-Month']
y2=df2['Rate']

x1=df1['Year-Month']
y1=df1['Rate']


fig, ax1 = plt.subplots(1, 1, figsize=(20,10))
ax1.plot(df2['Year-Month'], df2['Rate'], 'k.-', label='Time-Series Rate df2')
for x2,y2 in zip(x2,y2):
    label = '{0:,.2f}%'.format(y2)

    plt.annotate(label, (x2,y2), textcoords="offset points", xytext=(0,10), ha='center')
ax1.plot(df1['Year-Month'], df1['Rate'], 'k', label='Time-Series Rate df1')
for x1,y1 in zip(x1,y1):
    label = '{0:,.2f}%'.format(y1)

    plt.annotate(label, (x1,y1), textcoords="offset points", xytext=(0,10), ha='center')
ax1.fill_between(df2['Year-Month'],df2['Rate'],df1['Rate'], color='red',alpha=.25,label='AreaBetweenRates')
ax1.set_xlabel('Month')
ax1.set_ylabel('Rate %')
ax1.set_title('Rate Comparison', fontsize=14)
ax1.legend()

Here is my plot

0 Answers0