import pandas as pd
data = pd.read_csv("effort.csv")
data = data[["5%", "Expected", "95%"]]
d={"5%": [0], "95%": [0], "Expected": [0]}
data = data.append(pd.DataFrame(d, index=[len(data)], columns=["5%", "Expected", "95%"]))
data
data['Truth'] = len(data.index) - pd.Series(data.index) - 1
data
data['index'] = data.index
data_lng = pd.melt(data[["index", "Expected", "Truth"]], id_vars='index')
data_lng
%matplotlib inline
from ggplot import *
p = ggplot(aes(x='index'), data=data_lng) \
+ geom_area(mapping=aes(x="index", ymin="5%", ymax="95%", alpha=0.2), data=data, color="gray") \
+ geom_line(aes(x='index', y='value', linetype='variable'), data=data_lng) \
+ xlab("Day") + ylab("Estimate (days left)") + ggtitle("Effort estimate:\n90% confidence intervals")
p
ggsave("plot.png", p)
d2 = data[['5%', 'Expected', '95%', 'index']].copy()
d2['5%'] = data.ix[:, '5%'] - data.ix[:, 'Truth']
d2['95%'] = data.ix[:, '95%'] - data.ix[:, 'Truth']
d2['Expected'] = data.ix[:, 'Expected'] - data.ix[:, 'Truth']
d2
p2 = ggplot(aes(x='index'), data=d2)+ geom_hline(y=0, linestyle='dotted')\
+ geom_area(mapping=aes(ymin="5%", ymax="95%", alpha=0.2), color="gray") \
+ geom_line(aes(y='Expected')) \
+ xlab("Day") + ylab("Estimate - True (days left)") \
+ ggtitle("Error in effort estimate:\n90% confidence intervals") \
+ ylim(-15, 15)
# For some reason, this shows two inline images
p2
ggsave("plot2.png", p2)