I am trying to create a graph of the Treasury yield curve to compare rates from two separate dates. I'm having difficulty combining the two curves and creating a clean graph. My question is : how do I draw two yield curves together, with yields (rates) located on the y axis and maturities (2yr, 5yr, 10yr, 20yr, 30yr) located on the x axis?
import numpy as np
import pandas as pd
import datetime as dt
import pandas.io.data as web
import matplotlib.pyplot as plt
import Quandl as q
from pandas import DataFrame
import matplotlib
matplotlib.style.use('ggplot')
treasury = q.get("USTREASURY/YIELD", trim_start="2000-01-01", returns="pandas")
fig, ax = plt.subplots()
treas = DataFrame(treasury)
treas.drop(treas.columns[[0,1,2,3,5,7]], axis=1, inplace=True)
today = treas.iloc[-1:]
first = treas.iloc[:1]
first = first.T
today = today.T
ax.plot(first, 'o')
ax.plot(today, 'x')
plt.show()
Here's what my plot looks like now. I am trying to flip an axis, so that each exit curve is a line with markers.
Brian source
share