跳到主要内容

金融数据分析(十一)分析我国近25年来农村居民与城市居民享受基本公共卫生服务的变化情况

· 1 分钟阅读
Allen Ma

项目二:分析我国近25年来农村居民与城市居民享受基本公共卫生服务的变化情况(图表输出)

利用世界银行公开数据

# -*- coding: utf-8 -*-
"""
Created on Mon Sept 21 8:04:59 2020

@author: mly
"""
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import pandas as pd
from matplotlib import ticker

plt.rcParams['font.sans-serif'] = ['SimHei']
mpl.rcParams["axes.unicode_minus"] = False

df = pd.read_csv('basicsanit_china2000to2017.csv')

y = df['rural_sanit']
y1 = df['urban_sanit']
y2 = df['peopl_sanit']
x = df['year']

plt.figure()
ax = plt.gca()
plt.grid(axis="y")
plt.title('农村居民与城市居民享受基本公共卫生服务的变化情况')
plt.ylabel('服务数值')
plt.xlabel('年份')
ax.plot(x, y, '-rp', lw = 1.5, label = 'rural_sanit')
ax.plot(x, y1, '-gp', lw = 1.5, label = 'rural_sanit')
ax.plot(x, y2, '-bp', lw = 1.5, label = 'peopl_sanit')
ax.legend(loc = 'upper right')

plt.show()

运行结果:

在这里插入图片描述