[Tutor] inserting degrees symbol in plot title

questions anon questions.anon at gmail.com
Wed Aug 10 05:11:11 CEST 2011


I am creating a number of plots of temperature in degrees celsius and I
would like the title of the plot to have -  C°
Through a search I found a way to print the symbol

degree_symbol = unichr(176).encode("latin-1")
print degree_symbol

but when I add this to my plot title I receive a huge error (see below). I
have also tried copying (from word) and pasting the symbol into my title
(like I did at the beginning of this email) but this also receives a huge
error!
Any feedback will be greatly appreciated.


Traceback (most recent call last):
  File "D:\My Dropbox\Python_code\analysis_netcdf_subplots.py", line 75, in
<module>
    plt.show()
  File "C:\Python27\lib\site-packages\matplotlib\backend_bases.py", line 74,
in __call__
    manager.show()
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_wx.py",
line 1557, in show
    self.canvas.draw()
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 59, in draw
    FigureCanvasAgg.draw(self)
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py",
line 394, in draw
    self.figure.draw(self.renderer)
  File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in
draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 798, in
draw
    func(*args)
  File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in
draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1946, in
draw
    a.draw(renderer)
  File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in
draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Python27\lib\site-packages\matplotlib\text.py", line 526, in draw
    bbox, info = self._get_layout(renderer)
  File "C:\Python27\lib\site-packages\matplotlib\text.py", line 305, in
_get_layout
    clean_line, ismath = self.is_math_text(line)
  File "C:\Python27\lib\site-packages\matplotlib\text.py", line 989, in
is_math_text
    if cbook.is_math_text(s):
  File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 1793, in
is_math_text
    s = unicode(s)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 19:
ordinal not in range(128)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110810/138e5bca/attachment-0001.html>


More information about the Tutor mailing list