Dear Gökhan,

thanks a lot for your reply and help! I could solve some of my problems, others remain elusive.

On 16/03/10 07:59, Gökhan Sever wrote:
Probably you need a unicode font-set that contain all the characters for
those alphabets. You can look at this example to see a simple unicode
demonstration example.

Yes, I have done that, for example:

ylab = plt.ylabel(u'输入 2')

Make sure you are using the right font in your matplotlib.

Well, here I get stuck. I checked the fontList.cache, and all the relevant CJK fonts are listed in there. I then added some CJK font names to my /etc/matplotlibrc: (I am using Ubuntu 9.10)

#font.sans-serif     : SimHei, Adobe Song Std, Bitstream Vera Sans, ...
#font.cursive        : Apple Chancery, ...
#font.fantasy        : Comic Sans MS, ...
#font.monospace      : Adobe Fangsong Std, Bitstream Vera Sans Mono, ...

In addition, I also defined

rcParams['font.sans-serif'] = ['SimHei']

in my Python code (attached).

All to no avail. I am at a loss. I would greatly appreciate some help here!


You have to adjust your label to get it seen. You may try with:

xlab = plt.xlabel("my x-axes label")
xlab.set_position((0.2, 0.1))

This did not yield any results. With the above code, xlab.set_position((0.2, 0.1)), I change the position of the xlabel. But the problem is that my graph is cut before the xlabel has a chance to appear (see dea.png). Basically the graph ends right after the x-axis. What I thus need is more whitespace under my x-axis. But how?


Two ways I can think of are: annotate and text functions of pyplot api.
http://matplotlib.sourceforge.net/api/pyplot_api.html

This worked fine! What I did was to define

text( 1, 4.2, u'A')

etc.

Thanks for your ideas and insights!

David

<<attachment: dea.png>>

#!/usr/bin/python
# -*- coding: utf-8 -*-
# http://suyonggui.blog.sohu.com/115269389.html
# http://hi.baidu.com/lijiangshui/blog/item/a0aad703cd65ee7e3812bb49.html

import matplotlib.pyplot as plt
from pylab import *
#rcParams['figure.figsize'] = 3.56, 2.22
rcParams['figure.figsize'] = 3.6, 2.3
rcParams['axes.labelsize'] = 12.0
rcParams['font.sans-serif'] = ['SimHei']


label = ('A', 'B', 'C', 'E')
shuru1 = [1, 2, 4, 5]
shuru2 = [4, 2, 1, 1]

plt.plot([0,3], [0,3], 'k--', lw=1)
plt.plot([3], [3], 'ko', ms=4)
plt.plot(shuru1, shuru2, 'k-', lw=1)
plt.plot(shuru1, shuru2, 'ko', ms=4)

plt.axis([0, 6, 0, 5])

# plt.title('Title')
xlab = plt.xlabel(u'输入 1')
xlab.set_position((0.2, 0.1))
ylab = plt.ylabel(u'输入 2')

text( 1, 4.2, u'A')
text( 1.95, 2.2, u'B')
text( 4, 1.2, u'C')
text( 5, 1.2, u'E')
text( 3, 3.2, u'D')

plt.grid(True)
plt.show()
plt.savefig('dea.png')
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to