ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 25 Jun 2012 06:40:08 -0500Why Sage can not plot Chinese labelhttp://ask.sagemath.org/question/9109/why-sage-can-not-plot-chinese-label/ 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.<br>
But for the sage plot function, when I want to set label with some Chinese characters,it raise exception :<br>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u6211' in position 0: ordinal not in range(128).<br>
After I set the default encoding to UTF-8 in site.py,this exception does not raise again,but the Chinese characters are shown as box like [].
Below is my code:
p1=plot(sin,(-2*pi,2*pi),thickness=2.0,rgbcolor=(0.5,1,0),legend_label='sin(x)')
p2=plot(cos,(-2*pi,2*pi),thickness=3.0,color='purple',alpha=0.5,legend_label='cos(x)')
plt=p1+p2
x = u'\xd6\xd0\xb9\xfa\xc8\xcb'
plt.axes_labels((x,'y'))
show(plt)
Is there any solution?
I am sorry, it seems that this web site does not support Chinese, so I change the x Sun, 24 Jun 2012 21:53:57 -0500http://ask.sagemath.org/question/9109/why-sage-can-not-plot-chinese-label/Answer by shahuwang for <p>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.<br/>
But for the sage plot function, when I want to set label with some Chinese characters,it raise exception :<br/>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u6211' in position 0: ordinal not in range(128).<br/>
After I set the default encoding to UTF-8 in site.py,this exception does not raise again,but the Chinese characters are shown as box like [].
Below is my code:</p>
<pre><code>p1=plot(sin,(-2*pi,2*pi),thickness=2.0,rgbcolor=(0.5,1,0),legend_label='sin(x)')
p2=plot(cos,(-2*pi,2*pi),thickness=3.0,color='purple',alpha=0.5,legend_label='cos(x)')
plt=p1+p2
x = u'\xd6\xd0\xb9\xfa\xc8\xcb'
plt.axes_labels((x,'y'))
show(plt)
</code></pre>
<p>Is there any solution?
I am sorry, it seems that this web site does not support Chinese, so I change the x </p>
http://ask.sagemath.org/question/9109/why-sage-can-not-plot-chinese-label/?answer=13758#post-id-13758[My answer](http://ask.sagemath.org/question/1559/a-bug-in-graphicspy) Mon, 25 Jun 2012 04:33:33 -0500http://ask.sagemath.org/question/9109/why-sage-can-not-plot-chinese-label/?answer=13758#post-id-13758Comment by kcrisman for <p><a href="http://ask.sagemath.org/question/1559/a-bug-in-graphicspy">My answer</a> </p>
http://ask.sagemath.org/question/9109/why-sage-can-not-plot-chinese-label/?comment=19513#post-id-19513Though you may want to post a summary here. Also, can you think of a way of dealing with the matplotlibrc issue directly in Sage?Mon, 25 Jun 2012 05:40:17 -0500http://ask.sagemath.org/question/9109/why-sage-can-not-plot-chinese-label/?comment=19513#post-id-19513Comment by shahuwang for <p><a href="http://ask.sagemath.org/question/1559/a-bug-in-graphicspy">My answer</a> </p>
http://ask.sagemath.org/question/9109/why-sage-can-not-plot-chinese-label/?comment=19506#post-id-19506Yes , 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?Mon, 25 Jun 2012 06:40:08 -0500http://ask.sagemath.org/question/9109/why-sage-can-not-plot-chinese-label/?comment=19506#post-id-19506