Ask Your Question

Why Sage can not plot Chinese label

asked 2012-06-25 04:53:57 +0200

updated 2019-03-02 13:20:19 +0200

FrédéricC gravatar image

I know that Matplotlib does not support UTF-8 without some change in matplotlibrc,So I edit the matplotlibrc and now when plot with matplotlib in sagenb,it supports UTF-8 now and it can show Chinese now.
But for the sage plot function, when I want to set label with some Chinese characters,it raise exception :
UnicodeEncodeError: 'ascii' codec can't encode character u'\u6211' in position 0: ordinal not in range(128).
After I set the default encoding to UTF-8 in,this exception does not raise again,but the Chinese characters are shown as box like []. Below is my code:

x = u'\xd6\xd0\xb9\xfa\xc8\xcb'


Is there any solution? I am sorry, it seems that this web site does not support Chinese, so I change the x

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2012-06-25 11:33:33 +0200

edit flag offensive delete link more


Though you may want to post a summary here. Also, can you think of a way of dealing with the matplotlibrc issue directly in Sage?

kcrisman gravatar imagekcrisman ( 2012-06-25 12:40:17 +0200 )edit

Yes , it is my pleasure.But I don't know how to do so, as I have no experience on software development. Is it ok to send Email to you to submit my solution?

shahuwang gravatar imageshahuwang ( 2012-06-25 13:40:08 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-06-25 04:53:57 +0200

Seen: 447 times

Last updated: Jun 25 '12