Memberi anotasi pada data deret waktu

Pengantar Visualisasi Data dengan Matplotlib

Ariel Rokem

Data Scientist

Data deret waktu

Pengantar Visualisasi Data dengan Matplotlib

Anotasi

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

Pengantar Visualisasi Data dengan Matplotlib

Memposisikan teks

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

Pengantar Visualisasi Data dengan Matplotlib

Menambahkan panah ke anotasi

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

Pengantar Visualisasi Data dengan Matplotlib

Menyesuaikan properti panah

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

Pengantar Visualisasi Data dengan Matplotlib

Menyesuaikan anotasi

Pengantar Visualisasi Data dengan Matplotlib

Latihan memberi anotasi plot!

Pengantar Visualisasi Data dengan Matplotlib

Preparing Video For Download...