赞
踩
科研论文配图作为数据可视化在科研领域的重要应用场景,是研究结果直观、有效的呈现方式,在 学术论文、研究报告、专利申请、科研基金申请 等方面起着举足轻重的作用。不同学术期刊在图名、字体、坐标轴,以及颜色选择、配图格式等方面都有其特有的要求。论文只有符合投稿期刊的配图要求,才能进行下一步的查阅和审核。
如下图所示,为Xmind软件绘制的绘图基础简介知识点。
一个简单的表格是这么创建的:
原则 | 内容 |
---|---|
必要性原则 | 具体问题具体分析,如果配图可以起到补充说明文字、直观展示结果、引出下文内容等作用,那么它就是必要的 |
易读性原则 | 完整、准确的标题、标签和图例等可以有效地增强科研论文配图的易读性 |
一致性原则 | ①配图所表达出的内容与上下文或者指定内容描述一致;②配图数据与上下文保持一致;③插图比例尺和缩放比例大小保持一致;④类似配图各图层要素保持一致 |
绘图时可选择多种色彩模式,常见的色彩模式包括 RGB 色彩模式、CMYK 色彩模式和 HEX 色彩模式。
色轮(color wheel)又称色环,一般由 12 种基本颜色按照圆环方式排列组成。常见的色轮配色方案有单色配色方案、互补色配色方案、等距三角配色方案和四角配色方案等。
①单色配色方案的可视化条形图代码示例(使用ax.bar( )函数)
import numpy as np import pandas as pd import seaborn as sns import proplot as pplt import matplotlib.pyplot as plt from proplot import rc rc["font.family"] = "Times New Roman" rc["axes.labelsize"] = 15 rc['tick.labelsize'] = 13 rc["suptitle.size"] = 15 menMeans = (5, 15, 30, 40) menStd = (2, 3, 4, 5) ind = np.arange(4) width = 0.7 labels = ('A', 'B', 'C', 'D') colors = ["#1826B0","#4C59D8","#717BD8","#081272"] # 颜色配置 fig, ax = plt.subplots(figsize=(4, 3),dpi=100,facecolor="w") for name,value,err,label,color in zip(labels,menMeans,menStd,labels,colors): ax.bar(name,value,yerr=err,label=label,color=color,ec="k",lw=.8, capsize=5,error_kw={'linewidth':1}) for spine in ["top","right"]: ax.spines[spine].set_visible(False) ax.grid(False) ax.set_ylim(0,50) ax.legend(frameon=False,handlelength=1.5,handleheight=1.5) plt.show()
代码绘图结果:(可通过调整colors = [“#1826B0”,“#4C59D8”,“#717BD8”,“#081272”]来改变颜色)
互补色配色方案的可视化饼状图代码示例(使用ax.pie( )函数)
sizes = [20, 40, 25, 15]
labels = ['A','B','C','D',]
colors=["#1826B0","#4C59D8","#717BD8","#081272"]
fig,ax = plt.subplots(figsize=(4,3.5),dpi=100,facecolor="w")
explode = (0, 0., 0,0)
ax.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
shadow=False, startangle=90,colors=colors,
wedgeprops={'linewidth':.8, 'edgecolor': 'k'},
textprops={'size': 12,"color":"w"})
ax.legend(labels,loc ='upper left',fontsize=9,handlelength=1.2,handleheight=1.2)
plt.tight_layout()
plt.show()
②互补色配色方案的可视化条形图代码示例(使用ax.bar( )函数)
import numpy as np import pandas as pd import seaborn as sns import proplot as pplt import matplotlib.pyplot as plt from proplot import rc rc["font.family"] = "Times New Roman" rc["axes.labelsize"] = 15 rc['tick.labelsize'] = 13 rc["suptitle.size"] = 15 menMeans = (5, 15) menStd = (2, 5) ind = np.arange(2) labels = ('A', 'B', ) colors=["#1826B0","#FFBA00"] fig,ax = plt.subplots(figsize=(4,3),dpi=100,facecolor="w") for name,value,err,label,color in zip(labels,menMeans,menStd,labels,colors): ax.bar(name,value,yerr=err,label=label,color=color,ec="k",lw=.8, capsize=5,error_kw={'linewidth':1}) for spine in ["top","right"]: ax.spines[spine].set_visible(False) ax.grid(False) ax.set_ylim(0,25) ax.legend(loc="upper left",frameon=False, handlelength=1.5,handleheight=1.5) plt.show()
互补色配色方案的可视化饼状图代码示例(使用ax.pie( )函数)
sizes = [30, 70]
labels = ['A','B']
colors=["#1826B0","#FFBA00"]
fig,ax = plt.subplots(figsize=(4,3.5),dpi=100,facecolor="w")
explode = (0, 0.,)
ax.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
shadow=False, startangle=90,colors=colors,
wedgeprops={'linewidth':.8, 'edgecolor': 'k'},
textprops={'size': 12,"color":"w"})
ax.legend(labels,loc ='upper left',fontsize=9,handlelength=1.2,handleheight=1.2)
plt.tight_layout()
plt.show()
③等距三角配色方案的可视化图代码示例
import numpy as np import pandas as pd import seaborn as sns import proplot as pplt import matplotlib.pyplot as plt from proplot import rc rc["font.family"] = "Times New Roman" rc["axes.labelsize"] = 15 rc['tick.labelsize'] = 13 rc["suptitle.size"] = 15 # 利用等距三角配色方案绘制的可视化配图示例 menMeans = (5, 15, 35) menStd = (2, 3, 5) ind = np.arange(3) labels = ('A', 'B', 'C') colors=["#1D1AB2","#C9F600","#FF4C00"] fig,ax = plt.subplots(figsize=(4,3),dpi=100,facecolor="w") for name,value,err,label,color in zip(labels,menMeans,menStd,labels,colors): ax.bar(name,value,yerr=err,label=label,color=color,ec="k",lw=.8, capsize=5,error_kw={'linewidth':1}) for spine in ["top","right"]: ax.spines[spine].set_visible(False) ax.grid(False) ax.set_ylim(0,50) ax.legend(frameon=False,handlelength=1.5,handleheight=1.5) plt.show() # 利用等距三角配色方案绘制的可视化配图示例 sizes = [20, 50, 30] labels = ['A','B','C'] colors=["#1D1AB2","#C9F600","#FF4C00"] fig,ax = plt.subplots(figsize=(4,3.5),dpi=100,facecolor="w") explode = (0, 0., 0) ax.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%', shadow=False, startangle=90,colors=colors, wedgeprops={'linewidth':.8, 'edgecolor': 'k'}, textprops={'size': 12,"color":"w"}) ax.legend(labels,loc ='upper left',fontsize=9,handlelength=1.2,handleheight=1.2) plt.tight_layout() plt.show()
④四角配色方案的可视化图代码示例
import numpy as np import pandas as pd import seaborn as sns import proplot as pplt import matplotlib.pyplot as plt from proplot import rc rc["font.family"] = "Times New Roman" rc["axes.labelsize"] = 15 rc['tick.labelsize'] = 13 rc["suptitle.size"] = 15 # 利用等距三角配色方案绘制的可视化配图示例 menMeans = (5, 15, 35) menStd = (2, 3, 5) ind = np.arange(3) labels = ('A', 'B', 'C') colors=["#1D1AB2","#C9F600","#FF4C00"] fig,ax = plt.subplots(figsize=(4,3),dpi=100,facecolor="w") for name,value,err,label,color in zip(labels,menMeans,menStd,labels,colors): ax.bar(name,value,yerr=err,label=label,color=color,ec="k",lw=.8, capsize=5,error_kw={'linewidth':1}) for spine in ["top","right"]: ax.spines[spine].set_visible(False) ax.grid(False) ax.set_ylim(0,50) ax.legend(frameon=False,handlelength=1.5,handleheight=1.5) plt.show() # 利用等距三角配色方案绘制的可视化配图示例 sizes = [20, 50, 30] labels = ['A','B','C'] colors=["#1D1AB2","#C9F600","#FF4C00"] fig,ax = plt.subplots(figsize=(4,3.5),dpi=100,facecolor="w") explode = (0, 0., 0) ax.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%', shadow=False, startangle=90,colors=colors, wedgeprops={'linewidth':.8, 'edgecolor': 'k'}, textprops={'size': 12,"color":"w"}) ax.legend(labels,loc ='upper left',fontsize=9,handlelength=1.2,handleheight=1.2) plt.tight_layout() plt.show()
注意课程代码中需要安装import scienceplots库!!!
**下面我们对比Python中三种库的颜色主题(Matplotlib,Seaborn 和 SciencePlots) **
import numpy as np import pandas as pd import seaborn as sns import proplot as pplt import matplotlib.pyplot as plt import scienceplots from proplot import rc rc["font.family"] = "Times New Roman" rc["axes.labelsize"] = 13 rc['tick.labelsize'] = 11 rc["suptitle.size"] = 15 tips = sns.load_dataset("tips") # a)Matplotlib的默认颜色主题 matplotlib_colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728'] fig,ax = plt.subplots(figsize=(3,3.2),dpi=100,facecolor="w") ax = sns.violinplot(x="day", y="total_bill", data=tips, palette=matplotlib_colors, saturation=1) for spine in ["top","right"]: ax.spines[spine].set_visible(False) ax.grid(False) ax.set_ylim(-10,60) ax.set_xlabel("Class") ax.set_ylabel("Value") plt.tight_layout() plt.show() # b)Seaborn的默认颜色主题 fig,ax = plt.subplots(figsize=(3,3.2),dpi=100,facecolor="w") ax = sns.violinplot(x="day", y="total_bill", data=tips,saturation=1) for spine in ["top","right"]: ax.spines[spine].set_visible(False) ax.grid(False) ax.set_ylim(-10,60) ax.set_xlabel("Class") ax.set_ylabel("Value") plt.tight_layout() plt.show() # c)SciencePlots的默认颜色主题(需安装Scienceplots包(pip install SciencePlots),不同版本引用方式有所不同,请注意!) with plt.style.context(['science']): from proplot import rc rc["xtick.minor.visible"] = False rc["ytick.minor.visible"] = False rc["xtick.major.pad"] =5 fig,ax = plt.subplots(figsize=(3,3.2),dpi=100,facecolor="w") ax = sns.violinplot(x="day", y="total_bill", data=tips,saturation=1) for spine in ["top","right"]: ax.spines[spine].set_visible(False) ax.tick_params(top=False,right=False) ax.grid(False) ax.set_ylim(-10,60) ax.set_xlabel("Class") ax.set_ylabel("Value") plt.tight_layout() plt.show()
Matplotlib 库的颜色主题主要包括 3 种类型:单色系(sequential)、双色渐变色系(diverging)
和多色系(qualitative)
Seaborn 库同样也包含了以上色系,使用中Tips 数据集绘制的单色系、双色渐变色系和多色系可视化配图,如下图所示(具体为单色系中的 ylgnbu 色系、双色渐变色系中的 seismic 色系和多色系中的set1 色系)。
常用的配色工具有 Color Scheme Designer 网站中的高级在线配色器、Adobe 旗下的在线配色工具 Adobe Color 和颜色主题搭配网站 ColorBrewer 2.0。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。