COVID-19: 緊急事態宣言と日本の感染者数の推移, python ver. 3

Last Updated on





Creating Chart Annotations using Matplotlib




# import libraries 
import pandas as pd
from matplotlib import pyplot as plt
from covid19dh import covid19
import datetime as dt
# load the data
x = covid19(verbose=False)
# infected japan
japan = x[x["administrative_area_level_1"]=="Japan"]
# create a line plot with texts
japan = japan.set_index('date')
ax = japan['confirmed'].plot(color='#334f8d', figsize=(11,8),
                             title='Confirmed in Japan 20200729')
# Annotate
x_line1 = dt.datetime(2020,4,8)
x_line2 = dt.datetime(2020,5,25)
x_text1 = dt.datetime(2020,4,8)
x_text2 = dt.datetime(2020,5,25)
ax.axvline(x=x_line1, linestyle='dashed', alpha=0.5)
ax.axvline(x=x_line2, linestyle='dashed', alpha=0.5)
ax.text(x=x_text1, y=3800, s='Stay home restriction', alpha=0.7, color='#334f8d')
ax.text(x=x_text2, y=15500, s='Stay home restriction', alpha=0.7, color='#334f8d')









About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.