import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'Data': [np.sin(i) + 3 for i in np.arange(1, 11, 0.1)],
'Annotation': ['A'] * 10 + ['B'] * 20 + [np.nan] * 10 +
['C'] * 10 + ['D'] * 10 + [np.nan] * 20 +
['D'] * 20})
annotation_symbols = [i for i in df['Annotation'].unique() if not pd.isnull(i)]
df = pd.concat([df, pd.get_dummies(df['Annotation']).replace(0, np.nan)])
plt.style.use('ggplot')
ax = plt.figure(figsize=(7, 5)).add_subplot(111)
df.plot.line(x=df.index, y='Data', ax=ax)
df.plot.line(x=df.index, y=annotation_symbols, ax=ax)
:
