Adnotarea datelor de tip serie temporală

Introducere în vizualizarea datelor cu Matplotlib

Ariel Rokem

Data Scientist

Date de tip serie temporală

Introducere în vizualizarea datelor cu Matplotlib

Adnotare

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()

Introducere în vizualizarea datelor cu Matplotlib

Poziționarea textului

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

Introducere în vizualizarea datelor cu Matplotlib

Adăugarea săgeților la adnotare

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

Introducere în vizualizarea datelor cu Matplotlib

Personalizarea proprietăților săgeților

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

Introducere în vizualizarea datelor cu Matplotlib

Personalizarea adnotărilor

Introducere în vizualizarea datelor cu Matplotlib

Exersați adnotarea graficelor!

Introducere în vizualizarea datelor cu Matplotlib

Preparing Video For Download...