
import pandas
import matplotlib
import matplotlib.pyplot as plt
#设置颜色,最后一位表示透明度
maincolor=(42/256,87/256,141/256,1);
#设置字体为中文,大小为20,字体为雅黑
font={
'family':'SimHei',
'size':20}
matplotlib.rc('font',**font);
#导入数据
juzhen=pandas.read_csv('D://Python projects//reference data//5.8//data.csv')
#配置图形格式
figure=plt.figure(
figsize=(20,15),
dpi=50)
#获取到一个子图的对象,'111'代表把图形分为一行一列并且操作第一个子图
figure_sub=figure.add_subplot(111)
#设置坐标轴的范围为最大值的1.1倍
figure_sub.set_xlim([
0,
juzhen.GDP.max()*1.1])
figure_sub.set_ylim([
0,
juzhen.population.max()*1.1])
#矩阵分析不需要坐标轴,把坐标轴刻度设置为空
figure_sub.get_xaxis().set_ticks([])
figure_sub.get_yaxis().set_ticks([])
#设置形状、点的颜色和大小
figure_sub.scatter(
juzhen.GDP,juzhen.population,
alpha=0.5,s=200,marker="o",
edgec