在matplotlib中将特殊字符绘制为①

时间:2016-03-03 03:45:12

标签: python matplotlib character

我搜索互联网,在matplotlib中找不到像①这样的特殊字符 是否有代码表示'①'在图中显示?

现在,我使用:

## the ① character was found on the Internet, and I clipped it.
ax.text(0.425, 0.475, u'①', ha='center')   

我认为必须有一些功能来生成①,②,③,④......作为一种特殊的字符

1 个答案:

答案 0 :(得分:4)

带圆圈的数字从Unicode代码点0x2460开始,然后上升到20.所以只需编写一个返回所需字符的辅助函数:

def circled(x):
    return chr(0x245F+x)    # Python 2: use unichr() instead of chr()

用法:

ax.text(0.425, 0.475, circled(1), ha='center')