Tijdreeksdata annoteren

Introductie tot datavisualisatie met Matplotlib

Ariel Rokem

Data Scientist

Tijdreeksdata

Introductie tot datavisualisatie met Matplotlib

Annotatie

fig, ax = plt.subplots()
plot_timeseries(ax, climate_change.index, climate_change['co2'],
               'blue', 'Time', 'CO2 (ppm)')
ax2 = ax.twinx()
plot_timeseries(ax2, climate_change.index, 
                climate_change['relative_temp'],
               'red', 'Time', 'Relative temperature (Celsius)')

ax2.annotate(">1 degree", xy=(pd.Timestamp("2015-10-06"), 1))
plt.show()

Introductie tot datavisualisatie met Matplotlib

Tekst positioneren

ax2.annotate(">1 degree",
             xy=(pd.Timestamp('2015-10-06'), 1),
             xytext=(pd.Timestamp('2008-10-06'), -0.2))

Introductie tot datavisualisatie met Matplotlib

Pijlen toevoegen aan annotatie

ax2.annotate(">1 degree",
             xy=(pd.Timestamp('2015-10-06'), 1),
             xytext=(pd.Timestamp('2008-10-06'), -0.2),
             arrowprops={})

Introductie tot datavisualisatie met Matplotlib

Pijleigenschappen aanpassen

ax2.annotate(">1 degree",
             xy=(pd.Timestamp('2015-10-06'), 1),
             xytext=(pd.Timestamp('2008-10-06'), -0.2),
             arrowprops={"arrowstyle":"->", "color":"gray"})

Introductie tot datavisualisatie met Matplotlib

Annotaties aanpassen

Introductie tot datavisualisatie met Matplotlib

Laten we oefenen!

Introductie tot datavisualisatie met Matplotlib

Preparing Video For Download...