Problem with ticklabel

Most of my issues have been answered through previous posts, but this is such
a specific problem, that I can't find the answer anywhere. I'm new to
matplotlib and therefore learning some of the basic things. My code is:

import matplotlib
import matplotlib.pyplot as plt
import matplotlib.pylab as plb
import matplotlib.font_manager as font_manager
import numpy as np

#Changing font at once
##font = {'family' : 'monospace',
## 'weight' : 'bold',
## 'size' : 18}
##matplotlib.rc('font', **font)

#Changing font individually
axis_font = {'fontname':'Arial', 'size':'18'}
font_path = 'C:\Windows\Fonts\Arial.ttf'
font_prop = font_manager.FontProperties(fname=font_path, size=20)

x = np.genfromtxt('test.txt',
skiprows=(3),usecols=(0),delimiter='',dtype=None)
y =
np.genfromtxt('test.txt',skiprows=(3),usecols=(1),delimiter='',dtype=None)
z =
np.genfromtxt('test.txt',skiprows=(3),usecols=(2),delimiter='',dtype=None)

fig, ax1 = plt.subplots()
ax1.errorbar(x, y, fmt = 'b-', linewidth=3.0, xerr = 0.0, yerr = z,
label="Linear")
ax1.set_xlabel('x-values', **axis_font)
ax1.set_ylabel('linear y-values', color='b', **axis_font)
for tl in ax1.get_yticklabels():
    tl.set_color('b')
ax1.legend(loc=2, prop=font_prop)
for label in (ax1.get_xticklabels() + ax1.get_yticklabels()):
    label.set_fontname('Arial')
    label.set_fontsize(18)

ax2 = ax1.twinx()
y2 = np.exp(x)
ax2.errorbar(x, y2, fmt = 'r-', linewidth=3.0, xerr = 0.0, yerr = 1000*z,
label="Exponential")
ax2.set_ylabel('exponential y-values', color='r', **axis_font)
for tl in ax2.get_yticklabels():
    tl.set_color('r')
ax2.legend(loc=1, prop=font_prop)
for label in ax2.get_yticklabels():
    label.set_fontname('Arial')
    label.set_fontsize(18)
#ax2.ticklabel_format(axis='y', style='sci', scilimits=(-2,2))
ax2.get_yaxis().get_major_formatter().set_powerlimits((2,2))

plb.savefig('test.png', bbox_inches='tight')
plt.show()

Which generates the plot shown below.

test.png <http://matplotlib.1069221.n5.nabble.com/file/n44376/test.png>

Now the question is about the line (two ways of doing the same):
#ax2.ticklabel_format(axis='y', style='sci', scilimits=(-2,2))
ax2.get_yaxis().get_major_formatter().set_powerlimits((2,2))

As can be seen from the plot, the 1e4 has both a different size and color
than the rest of the y-axis. I have tried so many methods, but it just
remains the same no matter. Can anyone help?

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Problem-with-ticklabel-tp44376.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I think that "1e4" is a offset text, and not a part of ax2's yticklabels, so
any color or font settings for yticklabels will not affect it.

It's seems the offset text only uses matplotlib's default rcParams to draw,
so my solution is to change rcParams.

Try add these 4 lines before your plot code:

import matplotlib as mpl
mpl.rcParams['ytick.labelsize']='18'
mpl.rcParams['ytick.color']='r'
mpl.rcParams['font.sans-serif']='Arial'

What you set here will become default settings of matplotlib.
For more details of rcParams, check this:
http://matplotlib.org/users/customizing.html
<http://matplotlib.org/users/customizing.html>
I hope this will solve your problems.

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Problem-with-ticklabel-tp44376p44384.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

And it works perfectly, thank you very much!

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Problem-with-ticklabel-tp44376p44386.html
Sent from the matplotlib - users mailing list archive at Nabble.com.