带有特殊字符的绘图:“▬”

时间:2018-11-26 00:05:55

标签: python matplotlib unicode

我有以下代码,假定在绘图散点图中写入the字符(alt + 22)。但是,当我运行它时,它会显示“?”。有方向吗?

import matplotlib.pyplot as plt
import pandas as pd
import datetime
fig = plt.figure(facecolor="#979899")
ax = plt.gca()
ax.set_facecolor("#d1d1d1")
plt.grid(True)
plt.title("This is a title",fontsize=32)
plt.xticks([datetime.date(2018,11,20),datetime.date(2018,11,21),datetime.date(2018,11,22)],["11/20","11/21","11/22"])
plt.yticks([0,16,32],["0","16","32"])
x1 = [datetime.date(2018,11,20),datetime.date(2018,11,21),datetime.date(2018,11,22)]
y1 = [18,32,21]
for i,item in enumerate(y1):
    xP = x1[i]
    yP = y1[i]
    plt.text(xP,yP,str(item)+"▬",fontsize=11)
plt.plot(x1,y1,label="Some Legend A")
plt.scatter(x1,y1)
plt.legend()
plt.show()

0 个答案:

没有答案