Python分析数据【利用DataFame】--帮一个武大同学分析excel表格数据【记】

Excel数据格式截图:

主要分析cog数据在不同指标下随时间的变化,有2005 2008 2011 2014四个年度。prov是不同省份等等。

代码如下:

# -*- coding: utf-8 -*-
"""
Created on Fri May 24 09:56:04 2019

@author: YEXIN
@Company:华中科技大学

"""

import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
myfont = mpl.font_manager.FontProperties(fname='C:\Windows\Fonts\simsun.ttc')
##文件位置
ExcelFilePath=r'D:\PycharmWorks\YeXinPython\Others\cognitive(1).xlsx'

#读取excel数据到DataFrame里面
data = pd.read_excel(ExcelFilePath,sheet_name=0)##目标sheet所在的位置,以0为起始,比如sheet_name = 1代表第2个工作表
#print(data.head())

###数据筛选
data_2005=data.loc[(data['year']==2005)]##2005年数据
#data_2008=data.loc[(data['year']==2008)]##2008年数据
#data_2011=data.loc[(data['year']==2011)]##2011年数据
#data_2014=data.loc[(data['year']==2014)]##2014年数据

##指标列表
year_name=['2005','2008','2011','2014']
index_name=['整体','男性','女性','城市','镇','乡','东部','中部','西部']
index = ['obs','Mean','0-9分','10-17分','18-23分','24-30分']

##通过循环利用index_name,index;year_name生成指标组合,便于标明下面的DF的数据意义,方面后期画图
names=[]
names.append(year_name)

for i in range(len(index_name)):
    tmpnamelist = []
    for j in range(len(index)):
        tmpname = index_name[i]+':'+index[j]
        tmpnamelist.append(tmpname)
    names.append(tmpnamelist)
            
###认知能力:整体,男性,女性  数据DF
DataFrame_human = pd.DataFrame(index=names[0],columns=names[1]+names[2]+names[3]+['lower 24-man']+['lower 24-women']+['lower 24'])
###认知能力,城市,镇,乡  数据DF
DataFrame_town = pd.DataFrame(index=names[0],columns=names[4]+names[5]+names[6]+['lower 24-城市']+['lower 24-镇']+['lower 24-乡']+['lower 24'])
###认知能力 东,中,西  数据DF
DataFrame_space = pd.DataFrame(index=names[0],columns=names[7]+names[8]+names[9]+['lower 24-东']+['lower 24-中']+['lower 24-西']+['lower 24'])

####数据处理并存储
'''
   以下筛选性别分布的认知能力
'''
human_human_Sex_num = data.groupby(['year','gender'])['cog'].count()
human_Mean_sex = data.groupby(['year','gender'])['cog'].agg([len,np.mean])##不同年度下不同性别的认知能力的均值
human_Sum_cog = data.groupby(['year'])['cog'].agg([len,np.mean])#总的认知能力:男+女
##0-9分
human_cog_0_9 = data.loc[(data['cog']<10) & (data['cog']>-1)].groupby(['year','gender'])['id'].count()
##10-17分
human_cog_10_17 = data.loc[(data['cog']>9) & (data['cog']<18)].groupby(['year','gender'])['id'].count()
##18-23分
human_cog_18_23 = data.loc[(data['cog']<24) & (data['cog']>17)].groupby(['year','gender'])['id'].count()
##24-30分
human_cog_24_30 = data.loc[(data['cog']<31) & (data['cog']>23)].groupby(['year','gender'])['id'].count()
##小于24分
human_cog_24 = data.loc[(data['cog']<25)].groupby(['year','gender'])['id'].count()


'''
   以下筛选城乡镇分布的认知能力
'''
town_resid_num = data.groupby(['year','resid'])['cog'].count()
town_Mean_resid = data.groupby(['year','resid'])['cog'].agg([len,np.mean])##不同年度下不同性别的认知能力的均值
town_Sum_cog = data.groupby(['year'])['cog'].agg([len,np.mean])#总的认知能力:男+女
##0-9分
town_cog_0_9 = data.loc[(data['cog']<10) & (data['cog']>-1)].groupby(['year','resid'])['id'].count()
##10-17分
town_cog_10_17 = data.loc[(data['cog']>9) & (data['cog']<18)].groupby(['year','resid'])['id'].count()
##18-23分
town_cog_18_23 = data.loc[(data['cog']<24) & (data['cog']>17)].groupby(['year','resid'])['id'].count()
##24-30分
town_cog_24_30 = data.loc[(data['cog']<31) & (data['cog']>23)].groupby(['year','resid'])['id'].count()
##小于24分
town_cog_24 = data.loc[(data['cog']<25)].groupby(['year','resid'])['id'].count()


'''
   以下筛选空间分布的认知能力
'''
space_prov_num = data.groupby(['year','prov_1'])['cog'].count()
space_Mean_prov = data.groupby(['year','prov_1'])['cog'].agg([len,np.mean])##不同年度下不同性别的认知能力的均值
space_Sum_cog = data.groupby(['year'])['cog'].agg([len,np.mean])#总的认知能力:男+女
##0-9分
space_cog_0_9 = data.loc[(data['cog']<10) & (data['cog']>-1)].groupby(['year','prov_1'])['id'].count()
##10-17分
space_cog_10_17 = data.loc[(data['cog']>9) & (data['cog']<18)].groupby(['year','prov_1'])['id'].count()
##18-23分
space_cog_18_23 = data.loc[(data['cog']<24) & (data['cog']>17)].groupby(['year','prov_1'])['id'].count()
##24-30分
space_cog_24_30 = data.loc[(data['cog']<31) & (data['cog']>23)].groupby(['year','prov_1'])['id'].count()
##小于24分
space_cog_24 = data.loc[(data['cog']<25)].groupby(['year','prov_1'])['id'].count()


for k in range(len(year_name)):
    #####存储到DataFrame_human
    DataFrame_human.iloc[k,0]=human_Mean_sex.iat[k*2,0]+human_Mean_sex.iat[k*2+1,0]##插入数据
    DataFrame_human.iloc[k,1]=human_Sum_cog.iat[k,1]
    DataFrame_human.iloc[k,2]=(human_cog_0_9[k*2]+human_cog_0_9[k*2+1])/human_Sum_cog.iat[k,0]
    DataFrame_human.iloc[k,3]=(human_cog_10_17[k*2]+human_cog_10_17[k*2+1])/human_Sum_cog.iat[k,0]
    DataFrame_human.iloc[k,4]=(human_cog_18_23[k*2]+human_cog_18_23[k*2+1])/human_Sum_cog.iat[k,0]
    DataFrame_human.iloc[k,5]=(human_cog_24_30[k*2]+human_cog_24_30[k*2+1])/human_Sum_cog.iat[k,0]
    
    DataFrame_human.iloc[k,6]=human_Mean_sex.iat[k*2,0]
    DataFrame_human.iloc[k,7]=human_Mean_sex.iat[k*2,1]
    DataFrame_human.iloc[k,8]=(human_cog_0_9[k*2])/human_Mean_sex.iat[k*2,0]
    DataFrame_human.iloc[k,9]=(human_cog_10_17[k*2])/human_Mean_sex.iat[k*2,0]
    DataFrame_human.iloc[k,10]=(human_cog_18_23[k*2])/human_Mean_sex.iat[k*2,0]
    DataFrame_human.iloc[k,11]=(human_cog_24_30[k*2])/human_Mean_sex.iat[k*2,0]
    
    DataFrame_human.iloc[k,12]=human_Mean_sex.iat[k*2+1,0]
    DataFrame_human.iloc[k,13]=human_Mean_sex.iat[k*2+1,1]
    DataFrame_human.iloc[k,14]=(human_cog_0_9[k*2+1])/human_Mean_sex.iat[k*2+1,0]
    DataFrame_human.iloc[k,15]=(human_cog_10_17[k*2+1])/human_Mean_sex.iat[k*2+1,0]
    DataFrame_human.iloc[k,16]=(human_cog_18_23[k*2+1])/human_Mean_sex.iat[k*2+1,0]
    DataFrame_human.iloc[k,17]=(human_cog_24_30[k*2+1])/human_Mean_sex.iat[k*2+1,0]
    ###小于24的
    DataFrame_human.iloc[k,18]=(human_cog_24[k*2])/human_Mean_sex.iat[k*2,0]
    DataFrame_human.iloc[k,19]=(human_cog_24[k*2+1])/human_Mean_sex.iat[k*2+1,0]
    DataFrame_human.iloc[k,20]=(human_cog_24[k*2+1]+human_cog_24[k*2])/human_Sum_cog.iat[k,0]
    
    ##########存储到DataFrame_town
    
    DataFrame_town.iloc[k,0]=town_Mean_resid.iat[k*3,0]##插入数据
    DataFrame_town.iloc[k,1]=town_Mean_resid.iat[k*3,1]
    DataFrame_town.iloc[k,2]=(town_cog_0_9[k*3])/town_Mean_resid.iat[k*3,0]
    DataFrame_town.iloc[k,3]=(town_cog_10_17[k*3])/town_Mean_resid.iat[k*3,0]
    DataFrame_town.iloc[k,4]=(town_cog_18_23[k*3])/town_Mean_resid.iat[k*3,0]
    DataFrame_town.iloc[k,5]=(town_cog_24_30[k*3])/town_Mean_resid.iat[k*3,0]
    
    DataFrame_town.iloc[k,6]=town_Mean_resid.iat[k*3+1,0]
    DataFrame_town.iloc[k,7]=town_Mean_resid.iat[k*3+1,1]
    DataFrame_town.iloc[k,8]=(town_cog_0_9[k*3+1])/town_Mean_resid.iat[k*3+1,0]
    DataFrame_town.iloc[k,9]=(town_cog_10_17[k*3+1])/town_Mean_resid.iat[k*3+1,0]
    DataFrame_town.iloc[k,10]=(town_cog_18_23[k*3+1])/town_Mean_resid.iat[k*3+1,0]
    DataFrame_town.iloc[k,11]=(town_cog_24_30[k*3+1])/town_Mean_resid.iat[k*3+1,0]
    
    DataFrame_town.iloc[k,12]=town_Mean_resid.iat[k*3+2,0]
    DataFrame_town.iloc[k,13]=town_Mean_resid.iat[k*3+2,1]
    DataFrame_town.iloc[k,14]=(town_cog_0_9[k*3+2])/town_Mean_resid.iat[k*3+2,0]
    DataFrame_town.iloc[k,15]=(town_cog_10_17[k*3+2])/town_Mean_resid.iat[k*3+2,0]
    DataFrame_town.iloc[k,16]=(town_cog_18_23[k*3+2])/town_Mean_resid.iat[k*3+2,0]
    DataFrame_town.iloc[k,17]=(town_cog_24_30[k*3+2])/town_Mean_resid.iat[k*3+2,0]
    ###小于24的
    DataFrame_town.iloc[k,18]=(town_cog_24[k*3])/town_Mean_resid.iat[k*3,0]
    DataFrame_town.iloc[k,19]=(town_cog_24[k*3+1])/town_Mean_resid.iat[k*3+1,0]
    DataFrame_town.iloc[k,20]=(town_cog_24[k*3+2])/town_Mean_resid.iat[k*3+2,0]
    DataFrame_town.iloc[k,21]=(town_cog_24[k*3+1]+town_cog_24[k*3]+town_cog_24[k*3+2])/town_Sum_cog.iat[k,0]
    
    ##########存储到DataFrame_space
    
    DataFrame_space.iloc[k,0]=space_Mean_prov.iat[k*3,0]##插入数据
    DataFrame_space.iloc[k,1]=space_Mean_prov.iat[k*3,1]
    DataFrame_space.iloc[k,2]=(space_cog_0_9[k*3])/space_Mean_prov.iat[k*3,0]
    DataFrame_space.iloc[k,3]=(space_cog_10_17[k*3])/space_Mean_prov.iat[k*3,0]
    DataFrame_space.iloc[k,4]=(space_cog_18_23[k*3])/space_Mean_prov.iat[k*3,0]
    DataFrame_space.iloc[k,5]=(space_cog_24_30[k*3])/space_Mean_prov.iat[k*3,0]
    
    DataFrame_space.iloc[k,6]=space_Mean_prov.iat[k*3+1,0]
    DataFrame_space.iloc[k,7]=space_Mean_prov.iat[k*3+1,1]
    DataFrame_space.iloc[k,8]=(space_cog_0_9[k*3+1])/space_Mean_prov.iat[k*3+1,0]
    DataFrame_space.iloc[k,9]=(space_cog_10_17[k*3+1])/space_Mean_prov.iat[k*3+1,0]
    DataFrame_space.iloc[k,10]=(space_cog_18_23[k*3+1])/space_Mean_prov.iat[k*3+1,0]
    DataFrame_space.iloc[k,11]=(space_cog_24_30[k*3+1])/space_Mean_prov.iat[k*3+1,0]
    
    DataFrame_space.iloc[k,12]=space_Mean_prov.iat[k*3+2,0]
    DataFrame_space.iloc[k,13]=space_Mean_prov.iat[k*3+2,1]
    DataFrame_space.iloc[k,14]=(space_cog_0_9[k*3+2])/space_Mean_prov.iat[k*3+2,0]
    DataFrame_space.iloc[k,15]=(space_cog_10_17[k*3+2])/space_Mean_prov.iat[k*3+2,0]
    DataFrame_space.iloc[k,16]=(space_cog_18_23[k*3+2])/space_Mean_prov.iat[k*3+2,0]
    DataFrame_space.iloc[k,17]=(space_cog_24_30[k*3+2])/space_Mean_prov.iat[k*3+2,0]
    ###小于24的
    DataFrame_space.iloc[k,18]=(space_cog_24[k*3])/space_Mean_prov.iat[k*3,0]
    DataFrame_space.iloc[k,19]=(space_cog_24[k*3+1])/space_Mean_prov.iat[k*3+1,0]
    DataFrame_space.iloc[k,20]=(space_cog_24[k*3+2])/space_Mean_prov.iat[k*3+2,0]
    DataFrame_space.iloc[k,21]=(space_cog_24[k*3+1]+space_cog_24[k*3]+space_cog_24[k*3+2])/space_Sum_cog.iat[k,0]
    
    
    
####################################################################################################
###画图【单个】
####################################################################################################
##p1,=plt.plot(DataFrame_human['整体:Mean'])
##p2,=plt.plot(DataFrame_human['男性:Mean'])
##p3,=plt.plot(DataFrame_human['女性:Mean'])
#    
#plt.figure(1)
#plt.plot(DataFrame_human['整体:Mean'])
#plt.plot(DataFrame_human['男性:Mean'])
#plt.plot(DataFrame_human['女性:Mean'])
# 
#ax = plt.gca() # gca = 'get current axis' 获取当前坐标
#ax.spines['bottom'].set_linewidth(1.5)
#ax.spines['left'].set_linewidth(1.5)
#ax.spines['top'].set_linewidth(1.5)
#ax.spines['right'].set_linewidth(1.5)
#
#plt.ylabel('认知能力均值',fontproperties = myfont,fontsize=11)
#plt.xlabel('年份',fontproperties = myfont,fontsize=11)
#plt.title('不同性别的认知能力均值随年份的变化',fontproperties = myfont,fontsize=13,fontweight='bold')
#plt.xticks(fontsize=11)
#plt.yticks(fontsize=11)
##plt.legend([p1,p2,p3],['Wohle','man','women'],loc='upper right')
#plt.legend((u'整体均值', u'男性均值',u'女性均值'),loc='best',prop=myfont)
##plt.show() 
################################################################################
#plt.figure(2)  
#plt.plot(DataFrame_human['整体:0-9分'])
#plt.plot(DataFrame_human['男性:0-9分'])
#plt.plot(DataFrame_human['女性:0-9分'])
#
#ax = plt.gca() # gca = 'get current axis' 获取当前坐标
#ax.spines['bottom'].set_linewidth(1.2)
#ax.spines['left'].set_linewidth(1.2)
#ax.spines['top'].set_linewidth(1.2)
#ax.spines['right'].set_linewidth(1.2)
# 
#plt.ylabel('百分比',fontproperties = myfont,fontsize=11)
#plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
#plt.title('不同性别的认知能力百分比【0-9分】随年份的变化',fontproperties = myfont,fontsize=13,fontweight='bold')
#plt.xticks(fontsize=11)
#plt.yticks(fontsize=11)
#plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
##plt.show() 
################################################################################
#plt.figure(3)   
#plt.plot(DataFrame_human['整体:10-17分'])
#plt.plot(DataFrame_human['男性:10-17分'])
#plt.plot(DataFrame_human['女性:10-17分'])
#
#ax = plt.gca() # gca = 'get current axis' 获取当前坐标
#ax.spines['bottom'].set_linewidth(1.2)
#ax.spines['left'].set_linewidth(1.2)
#ax.spines['top'].set_linewidth(1.2)
#ax.spines['right'].set_linewidth(1.2)
# 
#plt.ylabel('百分比',fontproperties = myfont,fontsize=11)
#plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
#plt.title('不同性别的认知能力百分比【10-17分】随年份的变化',fontproperties = myfont,fontsize=13,fontweight='bold')
#plt.xticks(fontsize=11)
#plt.yticks(fontsize=11)
#plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
##plt.show() 
################################################################################
#plt.figure(4)   
#plt.plot(DataFrame_human['整体:18-23分'])
#plt.plot(DataFrame_human['男性:18-23分'])
#plt.plot(DataFrame_human['女性:18-23分'])
#
#ax = plt.gca() # gca = 'get current axis' 获取当前坐标
#ax.spines['bottom'].set_linewidth(1.2)
#ax.spines['left'].set_linewidth(1.2)
#ax.spines['top'].set_linewidth(1.2)
#ax.spines['right'].set_linewidth(1.2)
# 
#plt.ylabel('百分比',fontproperties = myfont,fontsize=11)
#plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
#plt.title('不同性别的认知能力百分比【18-23分】随年份的变化',fontproperties = myfont,fontsize=13,fontweight='bold')
#plt.xticks(fontsize=11)
#plt.yticks(fontsize=11)
#plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
##plt.show() 
################################################################################
#plt.figure(5)   
#plt.plot(DataFrame_human['整体:24-30分'])
#plt.plot(DataFrame_human['男性:24-30分'])
#plt.plot(DataFrame_human['女性:24-30分'])
#
#ax = plt.gca() # gca = 'get current axis' 获取当前坐标
#ax.spines['bottom'].set_linewidth(1.2)
#ax.spines['left'].set_linewidth(1.2)
#ax.spines['top'].set_linewidth(1.2)
#ax.spines['right'].set_linewidth(1.2)
# 
#plt.ylabel('百分比',fontproperties = myfont,fontsize=11)
#plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
#plt.title('不同性别的认知能力百分比【24-30分】随年份的变化',fontproperties = myfont,fontsize=13,fontweight='bold')
#plt.xticks(fontsize=11)
#plt.yticks(fontsize=11)
#plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
##plt.show() 
################################################################################
#plt.figure(6)   
#plt.plot(DataFrame_human['lower 24'])
#plt.plot(DataFrame_human['lower 24-man'])
#plt.plot(DataFrame_human['lower 24-women'])
#
#ax = plt.gca() # gca = 'get current axis' 获取当前坐标
#ax.spines['bottom'].set_linewidth(1.2)
#ax.spines['left'].set_linewidth(1.2)
#ax.spines['top'].set_linewidth(1.2)
#ax.spines['right'].set_linewidth(1.2)
# 
#plt.ylabel('百分比',fontproperties = myfont,fontsize=11)
#plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
#plt.title('不同性别的认知能力百分比【低于24分】随年份的变化',fontproperties = myfont,fontsize=13,fontweight='bold')
#plt.xticks(fontsize=11)
#plt.yticks(fontsize=11)
#plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
#plt.show()
################################################################################
#######画图【单个】#########################



###################################################################################################
##画图【整合】DataFrame_human
###################################################################################################
plt.figure(1)
ax1 = plt.subplot(2, 3, 1) # (行,列,活跃区)
plt.plot(DataFrame_human['整体:Mean'])
plt.plot(DataFrame_human['男性:Mean'])
plt.plot(DataFrame_human['女性:Mean'])
 
ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.5)
ax.spines['left'].set_linewidth(1.5)
ax.spines['top'].set_linewidth(1.5)
ax.spines['right'].set_linewidth(1.5)

plt.ylabel('认知能力均值',fontproperties = myfont,fontsize=12)
plt.title('不同性别的认知能力均值随年份的变化',fontproperties = myfont,fontsize=9,fontweight='bold')
plt.xticks(fontsize=6)
plt.yticks(fontsize=11)
#plt.legend([p1,p2,p3],['Wohle','man','women'],loc='upper right')
plt.legend((u'整体均值', u'男性均值',u'女性均值'),loc='best',prop=myfont,fontsize=5)
#plt.show() 
###############################################################################
ax2 = plt.subplot(2, 3, 2)  
plt.plot(DataFrame_human['整体:0-9分'])
plt.plot(DataFrame_human['男性:0-9分'])
plt.plot(DataFrame_human['女性:0-9分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.title('不同性别的认知能力【0-9分】百分比随年份的变化',fontproperties = myfont,fontsize=9,fontweight='bold')
plt.xticks(fontsize=6)
plt.yticks(fontsize=6)
plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax3 = plt.subplot(2, 3, 3)  
plt.plot(DataFrame_human['整体:10-17分'])
plt.plot(DataFrame_human['男性:10-17分'])
plt.plot(DataFrame_human['女性:10-17分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比',fontproperties = myfont,fontsize=9)
ax.yaxis.set_label_position("right")
plt.title('不同性别的认知能力【10-17分】百分比随年份的变化',fontproperties = myfont,fontsize=9,fontweight='bold')
plt.xticks(fontsize=6)
plt.yticks(fontsize=6)
plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax4 = plt.subplot(2, 3, 4)   
plt.plot(DataFrame_human['整体:18-23分'])
plt.plot(DataFrame_human['男性:18-23分'])
plt.plot(DataFrame_human['女性:18-23分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比',fontproperties = myfont,fontsize=12)
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('不同性别的认知能力【18-23分】百分比随年份的变化',fontproperties = myfont,fontsize=8,fontweight='bold')
plt.xticks(fontsize=9)
plt.yticks(fontsize=11)
plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax5 = plt.subplot(2, 3, 5) 
plt.plot(DataFrame_human['整体:24-30分'])
plt.plot(DataFrame_human['男性:24-30分'])
plt.plot(DataFrame_human['女性:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('不同性别的认知能力【24-30分】百分比随年份的变化',fontproperties = myfont,fontsize=8,fontweight='bold')
plt.xticks(fontsize=9)
plt.yticks(fontsize=6)
plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax6 = plt.subplot(2, 3, 6)  
plt.plot(DataFrame_human['lower 24'])
plt.plot(DataFrame_human['lower 24-man'])
plt.plot(DataFrame_human['lower 24-women'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比',fontproperties = myfont,fontsize=9)
ax.yaxis.set_label_position("right")
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('不同性别的认知能力【低于24分】百分比随年份的变化',fontproperties = myfont,fontsize=8,fontweight='bold')
plt.xticks(fontsize=9)
plt.yticks(fontsize=6)
plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),loc='best',prop=myfont)
#plt.show()
###############################################################################
######画图【整合】DataFrame_human#########################


###################################################################################################
##画图【整合】DataFrame_town
###################################################################################################
plt.figure(2)
ax1 = plt.subplot(2, 3, 1) # (行,列,活跃区)
plt.plot(DataFrame_town['城市:Mean'])
plt.plot(DataFrame_town['镇:Mean'])
plt.plot(DataFrame_town['乡:Mean'])
 
ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.5)
ax.spines['left'].set_linewidth(1.5)
ax.spines['top'].set_linewidth(1.5)
ax.spines['right'].set_linewidth(1.5)

plt.ylabel('认知能力均值',fontproperties = myfont,fontsize=12)
plt.title('城乡分布的认知能力均值随年份变化',fontproperties = myfont,fontsize=9,fontweight='bold')
plt.xticks(fontsize=6)
plt.yticks(fontsize=11)
#plt.legend([p1,p2,p3],['Wohle','man','women'],loc='upper right')
plt.legend((u'城市群体均值', u'镇群体均值',u'乡群体均值'),loc='best',prop=myfont,fontsize=5)
#plt.show() 
###############################################################################
ax2 = plt.subplot(2, 3, 2)  
plt.plot(DataFrame_town['城市:0-9分'])
plt.plot(DataFrame_town['镇:0-9分'])
plt.plot(DataFrame_town['乡:0-9分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.title('认知能力【0-9分】城乡分布百分比随年份的变化',fontproperties = myfont,fontsize=9,fontweight='bold')
plt.xticks(fontsize=6)
plt.yticks(fontsize=6)
plt.legend((u'占城市群体百分比',u'占镇群体百分比',u'占乡群体百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax3 = plt.subplot(2, 3, 3)  
plt.plot(DataFrame_town['城市:10-17分'])
plt.plot(DataFrame_town['镇:10-17分'])
plt.plot(DataFrame_town['乡:10-17分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比',fontproperties = myfont,fontsize=9)
ax.yaxis.set_label_position("right")
plt.title('认知能力【10-17分】城乡分布百分比随年份的变化',fontproperties = myfont,fontsize=9,fontweight='bold')
plt.xticks(fontsize=6)
plt.yticks(fontsize=6)
plt.legend((u'占城市群体百分比',u'占镇群体百分比',u'占乡群体百分比'),loc='best',prop=myfont)
#plt.show() 
plt.close()
###############################################################################
ax4 = plt.subplot(2, 3, 4)   
plt.plot(DataFrame_town['城市:18-23分'])
plt.plot(DataFrame_town['镇:18-23分'])
plt.plot(DataFrame_town['乡:18-23分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比',fontproperties = myfont,fontsize=12)
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('认知能力【18-23分】城乡分布百分比随年份的变化',fontproperties = myfont,fontsize=8,fontweight='bold')
plt.xticks(fontsize=9)
plt.yticks(fontsize=11)
plt.legend((u'占城市群体百分比',u'占镇群体百分比',u'占乡群体百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax5 = plt.subplot(2, 3, 5) 
plt.plot(DataFrame_town['城市:24-30分'])
plt.plot(DataFrame_town['镇:24-30分'])
plt.plot(DataFrame_town['乡:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('认知能力【24-30分】城乡分布百分比随年份的变化',fontproperties = myfont,fontsize=8,fontweight='bold')
plt.xticks(fontsize=9)
plt.yticks(fontsize=6)
plt.legend((u'占城市群体百分比',u'占镇群体百分比',u'占乡群体百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax6 = plt.subplot(2, 3, 6)  
plt.plot(DataFrame_town['lower 24'])
plt.plot(DataFrame_town['lower 24-城市'])
plt.plot(DataFrame_town['lower 24-镇'])
plt.plot(DataFrame_town['lower 24-乡'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比',fontproperties = myfont,fontsize=9)
ax.yaxis.set_label_position("right")
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('认知能力【低于24分】城乡分布百分比随年份的变化',fontproperties = myfont,fontsize=8,fontweight='bold')
plt.xticks(fontsize=9)
plt.yticks(fontsize=6)
plt.legend((u'占整体百分比', u'占城市群体百分比',u'占镇群体百分比',u'占乡群体百分比'),loc='best',prop=myfont)
#plt.show()
plt.close()
###############################################################################
######画图【整合】DataFrame_town#########################

###################################################################################################
##画图【整合】DataFrame_space
###################################################################################################
plt.figure(3)
ax1 = plt.subplot(2, 3, 1) # (行,列,活跃区)
plt.plot(DataFrame_space['东部:Mean'])
plt.plot(DataFrame_space['中部:Mean'])
plt.plot(DataFrame_space['西部:Mean'])
 
ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.5)
ax.spines['left'].set_linewidth(1.5)
ax.spines['top'].set_linewidth(1.5)
ax.spines['right'].set_linewidth(1.5)

plt.ylabel('认知能力均值',fontproperties = myfont,fontsize=12)
plt.title('认知能力均值空间随年份变化',fontproperties = myfont,fontsize=9,fontweight='bold')
plt.xticks(fontsize=6)
plt.yticks(fontsize=11)
#plt.legend([p1,p2,p3],['Wohle','man','women'],loc='upper right')
plt.legend((u'东部省份均值', u'中部省份均值',u'西部省份均值'),loc='best',prop=myfont,fontsize=5)
#plt.show() 
###############################################################################
ax2 = plt.subplot(2, 3, 2)  
plt.plot(DataFrame_space['东部:0-9分'])
plt.plot(DataFrame_space['中部:0-9分'])
plt.plot(DataFrame_space['西部:0-9分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.title('认知能力【0-9分】空间百分比随年份的变化',fontproperties = myfont,fontsize=9,fontweight='bold')
plt.xticks(fontsize=6)
plt.yticks(fontsize=6)
plt.legend((u'占东部省份百分比',u'占中部省份百分比',u'占西部省份百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax3 = plt.subplot(2, 3, 3)  
plt.plot(DataFrame_space['东部:10-17分'])
plt.plot(DataFrame_space['中部:10-17分'])
plt.plot(DataFrame_space['西部:10-17分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比',fontproperties = myfont,fontsize=9)
ax.yaxis.set_label_position("right")
plt.title('认知能力【10-17分】空间百分比随年份的变化',fontproperties = myfont,fontsize=9,fontweight='bold')
plt.xticks(fontsize=6)
plt.yticks(fontsize=6)
plt.legend((u'占东部省份百分比',u'占中部省份百分比',u'占西部省份百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax4 = plt.subplot(2, 3, 4)   
plt.plot(DataFrame_space['东部:18-23分'])
plt.plot(DataFrame_space['中部:18-23分'])
plt.plot(DataFrame_space['西部:18-23分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比',fontproperties = myfont,fontsize=12)
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('认知能力【18-23分】空间百分比随年份的变化',fontproperties = myfont,fontsize=8,fontweight='bold')
plt.xticks(fontsize=9)
plt.yticks(fontsize=11)
plt.legend((u'占东部省份百分比',u'占中部省份百分比',u'占西部省份百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax5 = plt.subplot(2, 3, 5) 
plt.plot(DataFrame_space['东部:24-30分'])
plt.plot(DataFrame_space['中部:24-30分'])
plt.plot(DataFrame_space['西部:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('认知能力【24-30分】空间百分比随年份的变化',fontproperties = myfont,fontsize=8,fontweight='bold')
plt.xticks(fontsize=9)
plt.yticks(fontsize=6)
plt.legend((u'占东部省份百分比',u'占中部省份百分比',u'占西部省份百分比'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax6 = plt.subplot(2, 3, 6)  
plt.plot(DataFrame_space['lower 24'])
plt.plot(DataFrame_space['lower 24-东'])
plt.plot(DataFrame_space['lower 24-中'])
plt.plot(DataFrame_space['lower 24-西'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比',fontproperties = myfont,fontsize=9)
ax.yaxis.set_label_position("right")
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('认知能力【低于24分】空间百分比随年份的变化',fontproperties = myfont,fontsize=8,fontweight='bold')
plt.xticks(fontsize=9)
plt.yticks(fontsize=6)
plt.legend((u'占东部省份百分比',u'占中部省份百分比',u'占西部省份百分比'),loc='best',prop=myfont)
#plt.show()
plt.close()
###############################################################################
######画图【整合】DataFrame_space#########################


############################各分段随时间变化############################################
############################DataFrame_human###########################################
plt.figure(4)
ax1 = plt.subplot(1, 3, 1)  
plt.plot(DataFrame_human['整体:0-9分'])
plt.plot(DataFrame_human['整体:10-17分'])
plt.plot(DataFrame_human['整体:18-23分'])
plt.plot(DataFrame_human['整体:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)

plt.ylabel('百分比',fontproperties = myfont,fontsize=10)
plt.xlabel('年份',fontproperties = myfont,fontsize=10,weight='heavy')
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
 
plt.title('整体认知能力百分比随年份的变化',fontproperties = myfont,fontsize=10,fontweight='bold')
plt.legend((u'0-9分', u'10-17分',u'18-23分','24-30分'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax2 = plt.subplot(1, 3, 2)  
plt.plot(DataFrame_human['男性:0-9分'])
plt.plot(DataFrame_human['男性:10-17分'])
plt.plot(DataFrame_human['男性:18-23分'])
plt.plot(DataFrame_human['男性:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.title('男性认知能力百分比随年份的变化',fontproperties = myfont,fontsize=10,fontweight='bold')
plt.xlabel('年份',fontproperties = myfont,fontsize=10,weight='heavy')
plt.xticks(fontsize=10)
plt.yticks(fontsize=6)
plt.legend((u'0-9分', u'10-17分',u'18-23分','24-30分'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax2 = plt.subplot(1, 3, 3)  
plt.plot(DataFrame_human['女性:0-9分'])
plt.plot(DataFrame_human['女性:10-17分'])
plt.plot(DataFrame_human['女性:18-23分'])
plt.plot(DataFrame_human['女性:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.title('女性认知能力百分比随年份的变化',fontproperties = myfont,fontsize=10,fontweight='bold')
plt.xlabel('年份',fontproperties = myfont,fontsize=10,weight='heavy')
plt.xticks(fontsize=10)
plt.yticks(fontsize=6)
plt.legend((u'0-9分', u'10-17分',u'18-23分','24-30分'),loc='best',prop=myfont)
#plt.show()
plt.close()

############################各分段随时间变化############################################
############################DataFrame_town###########################################
plt.figure(4)
ax1 = plt.subplot(1, 3, 1)  
plt.plot(DataFrame_town['城市:0-9分'])
plt.plot(DataFrame_town['城市:10-17分'])
plt.plot(DataFrame_town['城市:18-23分'])
plt.plot(DataFrame_town['城市:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)

plt.ylabel('百分比',fontproperties = myfont,fontsize=10)
plt.xlabel('年份',fontproperties = myfont,fontsize=10,weight='heavy')
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
 
plt.title('城市-认知能力百分比随年份的变化',fontproperties = myfont,fontsize=10,fontweight='bold')
plt.legend((u'0-9分', u'10-17分',u'18-23分','24-30分'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax2 = plt.subplot(1, 3, 2)  
plt.plot(DataFrame_town['镇:0-9分'])
plt.plot(DataFrame_town['镇:10-17分'])
plt.plot(DataFrame_town['镇:18-23分'])
plt.plot(DataFrame_town['镇:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.title('镇-认知能力百分比随年份的变化',fontproperties = myfont,fontsize=10,fontweight='bold')
plt.xlabel('年份',fontproperties = myfont,fontsize=10,weight='heavy')
plt.xticks(fontsize=10)
plt.yticks(fontsize=6)
plt.legend((u'0-9分', u'10-17分',u'18-23分','24-30分'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax2 = plt.subplot(1, 3, 3)  
plt.plot(DataFrame_town['乡:0-9分'])
plt.plot(DataFrame_town['乡:10-17分'])
plt.plot(DataFrame_town['乡:18-23分'])
plt.plot(DataFrame_town['乡:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.title('乡-认知能力百分比随年份的变化',fontproperties = myfont,fontsize=10,fontweight='bold')
plt.xlabel('年份',fontproperties = myfont,fontsize=10,weight='heavy')
plt.xticks(fontsize=10)
plt.yticks(fontsize=6)
plt.legend((u'0-9分', u'10-17分',u'18-23分','24-30分'),loc='best',prop=myfont)
#plt.show()
plt.close()

############################各分段随时间变化############################################
############################DataFrame_space###########################################
plt.figure(4)
ax1 = plt.subplot(1, 3, 1)  
plt.plot(DataFrame_space['东部:0-9分'])
plt.plot(DataFrame_space['东部:10-17分'])
plt.plot(DataFrame_space['东部:18-23分'])
plt.plot(DataFrame_space['东部:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)

plt.ylabel('百分比',fontproperties = myfont,fontsize=10)
plt.xlabel('年份',fontproperties = myfont,fontsize=10,weight='heavy')
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
 
plt.title('东部省份-认知能力百分比随年份的变化',fontproperties = myfont,fontsize=10,fontweight='bold')
plt.legend((u'0-9分', u'10-17分',u'18-23分','24-30分'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax2 = plt.subplot(1, 3, 2)  
plt.plot(DataFrame_space['中部:0-9分'])
plt.plot(DataFrame_space['中部:10-17分'])
plt.plot(DataFrame_space['中部:18-23分'])
plt.plot(DataFrame_space['中部:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.title('中部省份-认知能力百分比随年份的变化',fontproperties = myfont,fontsize=10,fontweight='bold')
plt.xlabel('年份',fontproperties = myfont,fontsize=10,weight='heavy')
plt.xticks(fontsize=10)
plt.yticks(fontsize=6)
plt.legend((u'0-9分', u'10-17分',u'18-23分','24-30分'),loc='best',prop=myfont)
#plt.show() 
###############################################################################
ax2 = plt.subplot(1, 3, 3)  
plt.plot(DataFrame_space['西部:0-9分'])
plt.plot(DataFrame_space['西部:10-17分'])
plt.plot(DataFrame_space['西部:18-23分'])
plt.plot(DataFrame_space['西部:24-30分'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.title('西部省份-认知能力百分比随年份的变化',fontproperties = myfont,fontsize=10,fontweight='bold')
plt.xlabel('年份',fontproperties = myfont,fontsize=10,weight='heavy')
plt.xticks(fontsize=10)
plt.yticks(fontsize=6)
plt.legend((u'0-9分', u'10-17分',u'18-23分','24-30分'),loc='best',prop=myfont)
plt.show()


##############低于24分的整合图####################################
################################################################
################################################################
plt.figure(7)
ax1 = plt.subplot(1, 3, 1)    
plt.plot(DataFrame_human['lower 24'])
plt.plot(DataFrame_human['lower 24-man'])
plt.plot(DataFrame_human['lower 24-women'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.ylabel('百分比(认知能力低于24分)',fontproperties = myfont,fontsize=11)
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('性别群体',fontproperties = myfont,fontsize=13,fontweight='bold')
plt.xticks(fontsize=11)
plt.yticks(fontsize=11)
plt.legend((u'占整体百分比', u'占男性群体百分比',u'占女性群体百分比'),prop=myfont,loc='upper left')
################################################################
ax2 = plt.subplot(1, 3, 2)    
plt.plot(DataFrame_town['lower 24'])
plt.plot(DataFrame_town['lower 24-城市'])
plt.plot(DataFrame_town['lower 24-镇'])
plt.plot(DataFrame_town['lower 24-乡'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('城乡分布',fontproperties = myfont,fontsize=13,fontweight='bold')
plt.xticks(fontsize=11)
plt.yticks(fontsize=6)
plt.legend((u'占整体百分比', u'占城市群体百分比',u'占镇群体百分比',u'占乡群体百分比'),loc='upper left',prop=myfont)
#############################################################
ax3 = plt.subplot(1, 3, 3)    
plt.plot(DataFrame_space['lower 24'])
plt.plot(DataFrame_space['lower 24-东'])
plt.plot(DataFrame_space['lower 24-中'])
plt.plot(DataFrame_space['lower 24-西'])

ax = plt.gca() # gca = 'get current axis' 获取当前坐标
ax.spines['bottom'].set_linewidth(1.2)
ax.spines['left'].set_linewidth(1.2)
ax.spines['top'].set_linewidth(1.2)
ax.spines['right'].set_linewidth(1.2)
 
plt.xlabel('年份',fontproperties = myfont,fontsize=11,weight='heavy')
plt.title('空间分布',fontproperties = myfont,fontsize=13,fontweight='bold')
plt.xticks(fontsize=11)
plt.yticks(fontsize=6)
plt.legend((u'占整体百分比', u'占东部省份百分比',u'占中部省份百分比',u'占西部省份百分比'),loc='upper left',prop=myfont)

plt.show()
    
    
 部分结果图展示【不能显示】:为防盗用,加水印了。   
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值