7

I have used the following function, but the label size isn't changing.

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)

I do not have enough reputation to post images. So I post it here: https://i.sstatic.net/aHRfk.jpg The sizes of the three labels never change, no matter how much the 'fontsize' tag is.

The original code is here:

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')
2
  • 1
    You can post a link to images. Also can you provide minimal, but full working code demonstrating your issue. Commented Mar 3, 2015 at 6:44
  • @Marcin Hello. The link and the partly full code is added. Commented Mar 3, 2015 at 8:43

1 Answer 1

14

You can try

params = {'axes.labelsize': 18,'axes.titlesize':20, 'text.fontsize': 20, 'legend.fontsize': 20, 'xtick.labelsize': 28, 'ytick.labelsize': 40}
matplotlib.rcParams.update(params)
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you very much! It works!! I am sorry I have no enough reputation to upvote... Why my former codes doesn't work btw??
I think , I have used similar to this,axd.set_xlabel(r"$D$ (nm)",color='blue',fontsize=28) in my code, but its inconsistent, it works sometimes, and sometimes it doesnt, so I changed to the current method mentioned in answer.
Thanks, this fixed my issue. It must have something to do with the subplot axes.
Fixed my issue as well, it was actually really hard to find this answer. Either way, thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.