首页 > 编程知识 正文

ppt中如何制作柱状数据分析,excel中柱状横坐标名称如何修改

时间:2023-05-03 06:41:50 阅读:226484 作者:249

先看画折线图观察两组数据的关联关系

我们举例,有两组数据,一组数据是dgp一组是对应的年份。那么我们可以画出年份与GDP的关系图,是上升还是下降来来来看代码。

#-*-coding:utf-8-*-

#**********************************

#**http://weibo.com/lixiaodaoaaa#

#**createat2017/5/2020:55***

#******by:lixiaodaoaaa***********

frommatplotlib.font_managerimportFontManager,FontProperties

importsubprocess

importmatplotlib.pyplotasplot

defgetChineseFont():

returnFontProperties(fname='/System/Library/Fonts/PingFang.ttc')

if__name__=='__main__':

years=[2010,2011,2012,2013,2014,2015,2016,2017]

gdps=[256,289,302,356,389,400,402,436]

plot.ylabel('gdp指标')

plot.xlabel("年份")

plot.plot(years,gdps,color='red',marker='o',line)

plot.title('年份与GDP的关系图',fontproperties=getChineseFont())

plot.show()

效果图如下:

同样的我们可以画一个柱状图:

#-*-coding:utf-8-*-

#**********************************

#**http://weibo.com/lixiaodaoaaa#

#**createat2017/5/2020:55***

#******by:lixiaodaoaaa***********

frommatplotlib.font_managerimportFontManager,FontProperties

importsubprocess

importmatplotlib.pyplotasplot

defgetChineseFont():

returnFontProperties(fname='/System/Library/Fonts/PingFang.ttc')

if__name__=='__main__':

years=[2010,2011,2012,2013,2014,2015,2016,2017]

gdps=[256,289,302,356,389,400,402,436]

plot.ylabel('gdp指标',fontproperties=getChineseFont())

plot.xlabel("年份",fontproperties=getChineseFont())

#plot.plot(years,gdps,color='red',marker='o',line)

plot.title('年份与GDP的关系图',fontproperties=getChineseFont())

plot.bar(years,gdps)

plot.show()

效果图如下

散点图

plot.scatter(years,gdps)

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。