3

I use matplotlib to do some plotting. But today I find out that it is very wired that in my plotting doesn't show the '-' on the y axis ticks. Could anyone give me some solutions for it? Thanks

The code is:

from pylab import *
import numpy
import scipy.io
from matplotlib.font_manager import FontProperties
from matplotlib import rc
rc('font',**{'family':'serif','serif':['Times New Roman'],'size':7})


figure(num=1, figsize=(2.9,2.4), dpi=300, facecolor='w', edgecolor='k')
x = np.linspace(0, 10, 1001, endpoint=True)
y = numpy.power(x/100, 3)
plot(x, y,'k-',label=r"Simulatied $\sigma_x$")
ylim(0,y.max())
ticklabel_format(style='sci',axis='y', scilimits=(0,0))
tight_layout()
savefig("xy.pdf")

(https://www.dropbox.com/s/rfpavget4rlyww7/yx.png)

It seems that this problem is caused by the font 'times new roman'. If I changed the font to 'Arial', the '-' appears

 rc('font',**{'family':'sans-serif','sans-serif':['Arial'],'size':20})

(https://www.dropbox.com/s/dfd76om86w7ji08/xy.png)

Paul Draper
  • 78,542
  • 46
  • 206
  • 285
  • Your code works OK for me even with Times (matplotlib 1.1.1 and python 2.7.3). Note that you can turn off the standard form label as shown here http://stackoverflow.com/a/14711866/1643946 - but obviously not appropriate for every case. – Bonlenfum Apr 22 '14 at 10:46

0 Answers0