简体   繁体   中英

Python - Print special characters

I've read this question and used it for my code. The problem is yesterday it worked and now it doesn't. As I know, I made zero change to my code.

fig1=plt.figure()
ax1=fig1.gca()
im1=ax1.imshow(tab_amp,cmap=cm.rainbow,extent=(0,90,-45,45),interpolation='bilinear')
ax1.set_xlabel(u'\u03b8 (°)')
ax1.set_ylabel(u'\u03c6 (°)')
cb1=fig1.colorbar(im1)
cb1.set_label(u'Amplitude de \u03b8ij (°)')
cs1 = ax1.contour(tab_amp_inv,colors='k',extent=(0,90,-45,45))
ax1.clabel(cs1, inline=1, fontsize=10,color='k')

It gives me this 在此处输入图片说明

Between yesterday an today, the only change I made to my computer is that I've installed prettyplotlib to change the default color of python. I don't know if that causes this problem?

It looks like the font lacks Unicode support. You can set the font directly when setting the labels, eg

ax1.set_xlabel(u'\u03b8 (°)', fontdict={'fontname': 'Times New Roman'})

That should override any defaults.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM