I am attempting to make a line graph showing home value change over the six months before a hurricane and the six months following a hurricane. I would like to add markers to each line with the value of the home at that time. I have the home value saved in a pandas DataFrame
that contains the month and value for each hurricane. I have been trying to use the matplotlib ax.annotate
function to do this, but have found no success.
import matplotlib.pyplot as plt
# Visualizing The Value Change of Homes Six Months Before and After Each Hurricane
# to set the plot size
fig = plt.figure()
# using plot method to plot values.
# in plot method we set the label and color of the curve.
charley_graph['value'].plot(label='Charley', color='orange', marker = 'o')
dennis_graph['value'].plot(label='Dennis')
matthew_graph['value'].plot(label='Matthew')
irma_graph['value'].plot(label='Irma')
michael_graph['value'].plot(label='Michael')
# adding title to the plot
plt.title('Top Tier Housing Value Change Six Months Before and After Each Hurricane')
# adding label to the x-axis
plt.xlabel('Months (0 = Hurricane Month)')
# adding label to the y-axis
plt.ylabel('House Value')
# adding legend to the curve
plt.legend();
#annotating
ax.annotate((charley_graph['value']), 'xy')
Which returns the graph, but with no annotations and this error.
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().