我使用了以下功能,但标签尺寸没有变化。
axe.set_xlabel('$R^{-1}_m$ (nm$^{-1}$)')
axe.xaxis.label.set_size(18)
axe.set_ylabel('$E_{f}/l_{z}$ (eV/nm)',fontsize=40)
axd.set_xlabel(r"$D$ (nm)",color='blue',fontsize=28)
我没有足够的声誉来发布图片。所以我在这里发布:http://imgur.com/T2pbd9B 无论字体大小多少,三个标签的大小都不会改变。标签是。
原始代码在这里:
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA
from matplotlib.patches import Rectangle
colormap = {'0':'yellow','1':'Indigo','2':'pink','3':'blue','4':'magenta','5':'orange','6':'cyan','7':'chartreuse','8':'royalblue','9':'red','10':'navy',}
markershape={'0':'o','1':vec1,'2':rotate_vec(vec2),'3':'^','4':'s','5':'p','6':'H','7':(7,0,0),'8':'8','9':(9,0,0),'10':(10,0,90),}
mksz=12
markersizemap={'0':mksz,'1':mksz*1.1,'2':mksz*1.1,'3':mksz*0.9,'4':mksz*0.8,'5':mksz,'6':mksz,'7':mksz,'8':mksz*1.1,'9':mksz*1.2,'10':mksz*1.2,}
fitxx = np.arange(4)
e_xmin=0.8;e_xmax=2.1;e_ymin=20;e_ymax=38
fig=plt.figure(num=None, figsize=(8,6), dpi=110, facecolor='w', edgecolor='k')
ax0 = host_subplot(111, axes_class=AA.Axes)
rec=Rectangle((e_xmin,e_ymin), e_xmax-e_xmin, e_ymax-e_ymin, ec="w",fc='lightgrey',alpha=0.4)
ax0.add_patch(rec)
for nn in range(len(lstall)):
fityy=aaa(nn)*fitxx+bbb(nn)
ax0.plot(fitxx,fityy,'--',color=colormap['%d'%nn],linewidth=2)
ax0.plot(lstall[nn][:,0],lstall[nn][:,1],marker=markershape['%d'%nn],markersize=markersizemap['%d'%nn],color=colormap['%d'%nn],label="n={}".format(nn),linestyle='None')
ax0.set_xlabel(r'$R^{-1}_m$ (nm$^{-1}$)')
ax0.xaxis.label.set_size(18)
ax0.set_ylabel(r'$E_{f}/l_{z}$ (eV/nm)',fontsize=100)
xmax=2.1
ax0.set_xlim((0, xmax));ax0.set_ylim((0, 62));ax0.grid(False)
axd = ax0.twiny();axd.grid()
dticklabels =['9','7','6','5','4','3','2','1.5','1','%.2f'%(2/xmax)]
def tick_function(X):
V=[]
for dd in X:
kk = 2/float(dd)
V.append(kk)
return V
curvticks=tick_function(dticklabels)
dticklabels.pop(-1)
dticklabels.append(' ')
axd.set_xticks(curvticks)
axd.set_xticklabels(dticklabels)
axd.set_xlabel(r"Diameter $D$ (nm)",color='blue',fontsize=28)
fig.savefig('%s/data1.png'%path,bbox_inches='tight')
fig.savefig('%s/data1.eps'%path,bbox_inches='tight')
答案 0 :(得分:5)
你可以尝试
params = {'axes.labelsize': 18,'axes.titlesize':20, 'text.fontsize': 20, 'legend.fontsize': 20, 'xtick.labelsize': 28, 'ytick.labelsize': 40}
matplotlib.rcParams.update(params)