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

Last Updated on

最新に更新しました。また、米国、中国、韓国を追加しました。

日本は、緊急事態宣言期間(4月8日から5月25日)を書き入れています。

次を参考にしました。

 

Creating Chart Annotations using Matplotlib

 

Spyderには、PandasとPyplotを使っていないと表示されます。Datetaimeにグラフ作成機能を組み込まれているのでしょうか。まだ調べていません。

 

# 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)
x
# 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),
                             fontsize=11, 
                             zorder=2,
                             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.