Plotting Treasury Yield Curve, How To Overlay Two Yield Curves Using Matplotlib
I am trying to create a graph of the treasury yield curve to compare the rates from two separate dates. I am having difficulty with combining the two curves and creating a clean gr
Solution 1:
Is this what you were looking for?
import matplotlib.pyplot as plt
import pandas as pd
import quandl as ql
#import Quandl as ql
%matplotlib inline
yield_ = ql.get("USTREASURY/YIELD")
today = yield_.iloc[-1,:]
month_ago = yield_.iloc[-30,:]
df = pd.concat([today, month_ago], axis=1)
df.columns = ['today', 'month_ago']
df.plot(style={'today': 'ro-', 'month_ago': 'bx--'}
,title='Treasury Yield Curve, %');
Post a Comment for "Plotting Treasury Yield Curve, How To Overlay Two Yield Curves Using Matplotlib"