騰訊課堂 | Python網絡爬蟲與文本分析python
01. 引言
(這種配色真的適合發sci論文)web
02. 基本繪製
import numpy as npimport matplotlib.pyplot as plt
plt.rcParams['font.family'] = "Times New Roman"
#datalabels = ['L1', 'L2', 'L3', 'L4', 'L5']data_a = [20, 34, 30, 35, 27]data_b = [25, 32, 34, 20, 25]data_c = [12, 20, 24, 17, 16]
x = np.arange(len(labels))width = .25#plotsfig,ax = plt.subplots(figsize=(5,3),dpi=200)bar_a = ax.bar(x-width/2, data_a,width,label='category_A')bar_b = ax.bar(x+width/2, data_b, width,label='category_B')bar_c = ax.bar(x+width*3/2, data_c,width,label='category_C')ax.set_xticks(x+.1)ax.set_xticklabels(labels,size=10)ax.legend() text_font = {'size':'14','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'E:\Data_resourses\DataCharm 公衆號\Python\學術圖表繪製\bar_class_prior.png',width=5,height=3, dpi=900,bbox_inches='tight')plt.show()
03. SCI配色設計
#構造數據labels = ['L1', 'L2', 'L3', 'L4', 'L5']data_a = [20, 34, 30, 35, 27]data_b = [25, 32, 34, 20, 25]data_c = [12, 20, 24, 17, 16]
x = np.arange(len(labels))width = .25
plt.rcParams['font.family'] = "Times New Roman"#plotsfig,ax = plt.subplots(figsize=(5,3),dpi=200)bar_a = ax.bar(x-width/2, data_a,width,label='category_A',color='#130074',ec='black',lw=.5)bar_b = ax.bar(x+width/2, data_b, width,label='category_B',color='#CB181B',ec='black',lw=.5)bar_c = ax.bar(x+width*3/2, data_c,width,label='category_C',color='white',ec='black',lw=.5)
#定製化設計ax.tick_params(axis='x',direction='in',bottom=False)ax.tick_params(axis='y',direction='out',labelsize=8,length=3)ax.set_xticks(x+1)ax.set_xticklabels(labels,size=10)ax.set_ylim(bottom=0,top=40)ax.set_yticks(np.arange(0, 50, step=5))
for spine in ['top','right']: ax.spines[spine].set_color('none') ax.legend(fontsize=7,frameon=False)
text_font = {'size':'14','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'E:\Data_resourses\DataCharm 公衆號\Python\學術圖表繪製\bar_class.png',width=5,height=3, dpi=900,bbox_inches='tight')plt.show()
bar_c = ax.bar(x+width*3/2, data_c,width,label='category_C',color='#008B45',ec='black',lw=.5)
此外,咱們還添加了網格線,感受還不錯,效果以下:微信
04. 總結
近期文章
Python網絡爬蟲與文本數據分析
rpy2庫 | 在jupyter中調用R語言代碼 tidytext | 耳目一新的R-style文本分析庫 reticulate包 | 在Rmarkdown中調用Python代碼 plydata庫 | 數據操做管道操做符>> plotnine: Python版的ggplot2做圖庫
七夕禮物 | 全網最火的釘子繞線圖製做教程
讀完本文你就瞭解什麼是文本分析
文本分析在經管領域中的應用概述 綜述:文本分析在市場營銷研究中的應用
plotnine: Python版的ggplot2做圖庫 小案例: Pandas的apply方法 stylecloud:簡潔易用的詞雲庫 用Python繪製近20年地方財政收入變遷史視頻 Wow~70G上市公司按期報告數據集
漂亮~pandas能夠無縫銜接Bokeh YelpDaset: 酒店管理類數據集10+G
本文分享自微信公衆號 - 大鄧和他的Python(DaDengAndHisPython)。
若有侵權,請聯繫 support@oschina.cn 刪除。
本文參與「OSC源創計劃」,歡迎正在閱讀的你也加入,一塊兒分享。markdown