import numpy as np
import matplotlib.dates as mdates
import pylab as plt
import datetime as dt
plt.mpl.rcParams [ 'font.sans-serif'] = [ 'SimHei']
plt.mpl.rcParams['axes.unicode_minus'] = False
date2_1 = dt.datetime(2020,1,23)
-
date2_2 = dt.datetime(2020,2,7)
delta2 = dt.timedelta (days = 1 )
dates2 = mdates .drange (date2_1, date2_2, delta2)
x = np.arange(1, 16, 1)
y = np.array([105,180,323,371,1291,840,1032,1220,1347,1921,2103,2345,3156,2987,2447])
y1 = np.array([ 250,444,680,760,1771,1450,1737,1982,2102,2580,2829,3235,3887,3694,3143])
y = np.array([105,180,323,371,1291,840,1032,1220,1347,1921,2103,2345,3156,2987,2447])
y1 = np.array([ 250,444,680,760,1771,1450,1737,1982,2102,2580,2829,3235,3887,3694,3143])
z1 = np.polyfit(x, y, 6)
p1 = np.poly1d(z1)
p1 = np.poly1d(z1)
z2 = np.polyfit(x, y1, 6)
p2= np.poly1d(z2)
p2= np.poly1d(z2)
plt.subplot (121) # line two, which is the first in FIG
plt.plot ( dates2 , Y, 'B', label = 'Wuhan diagnosis')
plt.plot ( dates2 , P1 (X), 'G', label = 'Wuhan trendline')
plt.title ( 'Wuhan number of people diagnosed with pneumonia curve')
plt.legend ()
plt.legend ()
max = plt.gca ()
for label in ax.xaxis.get_ticklabels():
label.set_rotation(90)
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d'))
ax.xaxis.set_major_locator(mdates.DayLocator())
plt.subplot (122)
plt.plot ( dates2 , Y1, 'B', label = 'National confirmed')
plt.plot ( dates2 , P2 (X), 'G', label = 'National trend line ")
plt.title ( 'the country the number of diagnosed pneumonia curve')
plt.legend ()
plt.legend ()
max = plt.gca ()
for label in ax.xaxis.get_ticklabels():
label.set_rotation(90)
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d'))
ax.xaxis.set_major_locator(mdates.DayLocator())
plt.show()