python常用图及其设置

常用图

基本要素

使用风格模板
# plt.style.use(['ieee'])
全局参数定义
rc={'font.family':"Times New Roman",
    'mathtext.fontset':'stix',
    'font.size':8}
matplotlib.rcParams.update(rc)
子图调整
plt.subplots_adjust(wspace=0.1,hspace=0.1)
设置小标题文字
ax[0].text(.03,.9,"(a)",transform = ax[0].transAxes,fontdict=text_font2,zorder=4)
图例设置
fig=plt.figure(figsize=(7,2),dpi=300)
ax = fig.subplots(ncols=3,nrows=1,sharey=True)

# 以fig为对象画全局图例
b,legend=fig.axes[2].get_legend_handles_labels()
# bbox_to_anchor=(0.33,0.9) 设置图例位置
fig.legend(legend,bbox_to_anchor=(0.33,0.9))
y轴设置
import matplotlib.ticker as mtick
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
ymajorLocator   = MultipleLocator(0.004)
ax[0][1].yaxis.set_major_locator(ymajorLocator)
ax[0][1].set_ylim([0.016,0.036])
ax[0][1].yaxis.set_major_formatter(mtick.FormatStrFormatter('%.3f'))

常用图

雷达图

ax = plt.subplot(131,polar=True)
ax.plot(angles, score_a,color='g',lw=0.5)

#角度设置
angles = np.linspace(0, 2*np.pi, data_length, endpoint=False)[::-1]+np.pi/3
#标签设置
ax.set_thetagrids(angles*180/np.pi, labels)
#设置起始位置
ax.set_theta_zero_location('N')
#设置外圈数值
ax.set_rlim(0, 2.5)
#设置标签位置
ax.set_rlabel_position(200)

热力图

#"orientation":"horizontal" 横放colormap
sns.heatmap(data3,ax=ax[2][0],cmap='summer',cbar_kws={"orientation":"horizontal","shrink":1})
#colorbar 设置
cbar = ax2.collections[0].colorbar
cbar.ax.set_xlim([0.048,0.059])

密度图

import seaborn as sns 
#denisty表示只显示密度曲线
sns.histplot(err,stat='density',color='#5799c6',ax=ax[0])

Q-Q图

import statsmodels.api as sm
fig1=sm.qqplot(data=err1,line='s',ax=ax[1],marker="o",c='b',markersize=2.0,lw=1.0)

包裹图

ax.fill_between(np.arange(0,len(data1_true[:,0])),data1_99[:,0],data1_99[:,1],alpha=1,color='#ccf2f2',label='99% interval')
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值