Issue
I want to print an axis label: "Temperature (℃)". How do I do it? A snippet is this:
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
x = range(10,60,1)
y = range(-100, 0, 2)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x,y)
ax.set_xlabel('Temperature (℃)')
For that last line I have tried:
ax.set_xlabel('Temperature (℃)'.encode('utf-8'))
ax.set_xlabel(u'Temperature (u\2103)')
ax.set_xlabel(u'Temperature (℃)')
ax.set_xlabel(u'Temperature (\u2103)')
ax.set_xlabel('Temperature (\u2103)')
I just don't get it. I'm using spyder and running the code from there.
Solution
Use the LaTeX interpreter to make the degree symbol.
ax.set_xlabel('Temperature ($^\circ$C)')
Here's the results:
Answered By - Carl F.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.