当前位置: 首页 > news >正文

win7 发布asp网站/企业建站平台

win7 发布asp网站,企业建站平台,微信端微网站怎么做,做盗版网站的引言在查找资料时看到了堆积柱状图,简单明了,而且绘制起来也不是很难,再结合自己的教程推文中也确实没有此类图表,即决定通过构建虚拟数据进行matplotlib堆积柱状图的绘制推文,详细内容如下:PS:…

引言

在查找资料时看到了堆积柱状图,简单明了,而且绘制起来也不是很难,再结合自己的教程推文中也确实没有此类图表,即决定通过构建虚拟数据进行matplotlib堆积柱状图的绘制推文,详细内容如下:

PS:如有需要Python学习资料的小伙伴可以加下方的群去找免费管理员领取

d9388033c712237a74e11fed720b538b.gif

可以免费领取源码项目实战视频PDF文件

a46dc14c24d999456b233b9c847a12f9.png

数据构建及默认可视化设置

结合此类图表特点,我们构建的数据结果如下:

6a24a137247372794742029f701de220.png

在matplotlib中要想绘制堆积柱状图,则需要灵活设置 ax.bar()绘图函数中bottom参数,先看一下简单的例子:

import matplotlib.pyplot as pltlabels = ['G1', 'G2', 'G3', 'G4', 'G5']
men_means = [20, 35, 30, 35, 27]
women_means = [25, 32, 34, 20, 25]
width = 0.35       # the width of the bars: can also be len(x) sequence
fig, ax = plt.subplots(figsize=(5,3),dpi=200)
ax.bar(labels, men_means, width,label='Men')
ax.bar(labels, women_means, width, bottom=men_means,label='Women')
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.legend()
ax.text(.87,-.08,'nVisualization by DataCharm',transform = ax.transAxes,ha='center', va='center',fontsize = 5,color='black',fontweight='bold',family='Roboto Mono')
plt.savefig(r'F:DataCharmSCI paper plotssci_bar_guanwang',width=5,height=3,dpi=900,bbox_inches='tight')
plt.show()

这里women 柱状图时,bottom设置为 men_means ,结果如下:

b4130a63a0f214d59cb01fe8a729cb16.png

看到这里,对柱状图的堆积应该有了一个较好的理解了吧

回到我们虚构的数据,使用默认的matplotlib参数,代码如下:

plt.rcParams['font.family'] = "Times New Roman"
fig,ax = plt.subplots(figsize=(8,5),dpi=200)label = [i for i in bar_data.columns[1:]]
mu_number = bar_data.iloc[0,1:].values
ma_number = bar_data.iloc[1,1:].values
en_number = bar_data.iloc[2,1:].values
ch_number = bar_data.iloc[3,1:].valueswidth = .4ax.bar(label, mu_number, width, label='Music',color='white',hatch="//",ec='k',lw=.6)
ax.bar(label, ma_number, width,  bottom=mu_number, label='Math',color='gray',ec='k',lw=.6)
ax.bar(label, en_number, width,  bottom=ma_number, label='English',color='white',hatch="...",ec='k',lw=.6)
ax.bar(label, ch_number, width,  bottom=en_number, label='Chinese',color='white',hatch="",ec='k',lw=.6)
ax.set_ylim(0,120)
ax.tick_params(direction='out',labelsize=12,length=5.5,width=1,top=False,right=False)
ax.legend(fontsize=11,frameon=False,loc='upper center',ncol=4)
ax.set_ylabel('Numbers of Studies',fontsize=13)
ax.set_xlabel('Time(year)',fontsize=13)
text_font = {'size':'17','weight':'bold','color':'black'}
ax.text(.03,.93,"(a)",transform = ax.transAxes,fontdict=text_font,zorder=4)
ax.text(.87,-.08,'nVisualization by DataCharm',transform = ax.transAxes,ha='center', va='center',fontsize = 5,color='black',fontweight='bold',family='Roboto Mono')
plt.savefig(r'F:DataCharmSCI paper plotssci_bar_04.png',width=5,height=3,dpi=900,bbox_inches='tight')

结果如下:

c06efb98cf012bb3ced8de35429aabd4.png

虽然效果也还不错,但想要达到出版的要求,可能还需要进行定制化需求设置。

可视化定制化设计

要想 达到一般出版社的要求,对其颜色、填充、刻度、轴脊、字体等都需要自行设置,具体代码如下:

plt.rcParams['font.family'] = "Times New Roman"
fig,ax = plt.subplots(figsize=(8,5),dpi=200)label = [i for i in bar_data.columns[1:]]
mu_number = bar_data.iloc[0,1:].values
ma_number = bar_data.iloc[1,1:].values
en_number = bar_data.iloc[2,1:].values
ch_number = bar_data.iloc[3,1:].valueswidth = .4ax.bar(label, mu_number, width, label='Music',color='white',hatch="//",ec='k',lw=.6)
ax.bar(label, ma_number, width,  bottom=mu_number, label='Math',color='gray',ec='k',lw=.6)
ax.bar(label, en_number, width,  bottom=ma_number, label='English',color='white',hatch="...",ec='k',lw=.6)
ax.bar(label, ch_number, width,  bottom=en_number, label='Chinese',color='white',hatch="",ec='k',lw=.6)
ax.set_ylim(0,120)
ax.tick_params(direction='out',labelsize=12,length=5.5,width=1,top=False,right=False)
ax.legend(fontsize=11,frameon=False,loc='upper center',ncol=4)
ax.set_ylabel('Numbers of Studies',fontsize=13)
ax.set_xlabel('Time(year)',fontsize=13)
text_font = {'size':'17','weight':'bold','color':'black'}
ax.text(.03,.93,"(a)",transform = ax.transAxes,fontdict=text_font,zorder=4)
ax.text(.87,-.08,'nVisualization by DataCharm',transform = ax.transAxes,ha='center', va='center',fontsize = 5,color='black',fontweight='bold',family='Roboto Mono')
plt.savefig(r'F:DataCharmSCI paper plotssci_bar_04.png',width=5,height=3,dpi=900,bbox_inches='tight')

结果如下:

34d42aca6b83ac67d669c6c149925382.png

有的时候对轴脊的设置也有很严的要求,通过添加如下代码,即可对轴脊进行设置:

for spine in ['bottom','left']:ax.spines[spine].set_linewidth(1.5)ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)

结果如下:

0e4ef149d7ac9b76580ea75b5d5a1db8.png

本文的文字及图片来源于网络,仅供学习、交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理。

以上文章来源于DataCharm,作者宁海涛

http://www.jmfq.cn/news/4854889.html

相关文章:

  • 外贸自建独立站/推广软文代写
  • 广西桂川建设集团网站/网络营销概述
  • 企业网站架构/百度学术论文查重官网入口
  • 专业网站制作设/网站推广步骤
  • 南通代办公司注册连锁/谷歌优化是什么意思
  • 湖南做网站360o/游戏推广平台代理
  • 企业做网站需要什么/域名注册需要多少钱
  • 营销型网站有哪些app/中企动力做网站推广靠谱吗
  • 网站前端/百度开户
  • 上海网站建设网络推广/百度网站制作联系方式
  • 交互式网站开发技术/百度竞价包年推广公司
  • 网站对于企业的好处/seo标签优化
  • 服装设计自学零基础/网站的seo如何优化
  • 厦门百度推广优化排名/seo去哪里学
  • 网站页面设计图是用什么软件画的/影响关键词优化的因素
  • 泰兴做网站/厦门网络营销推广
  • 专注做动漫的门户网站/如何seo推广
  • wordpress 后台进不去_如何替换主题/合肥百度推广排名优化
  • 外贸独立网站做仿品/整站优化和关键词优化的区别
  • 企业信息管理系统案例/台州seo排名优化
  • 如何自己办网站/域名注册多少钱
  • 杭州招标信息网/电脑网络优化软件
  • 网站搭建团队/淘宝指数在线查询
  • 网站托管服务适合/微信推广怎么弄
  • 图解asp.net网站开发实战/今天新闻头条新闻
  • 在线看网站建设/湖南平台网站建设制作
  • 怎样做购物网站/游戏加盟
  • 小程序做网站/天津优化公司
  • 品牌型网站建设哪里好/网站百度不收录的原因
  • 团购做的好的网站/线上营销平台