MatplotLib:带有URL链接的Unicode字符分散

MatplotLib:带有URL链接的Unicode字符分散,matplotlib,svg,unicode-literals,Matplotlib,Svg,Unicode Literals,我想将matplotlib散点图导出为SVG,每个散点具有不同的超链接,这些散点不是简单的标记,而是Unicode字符 我尝试了以下方法: import matplotlib.cm as cm import matplotlib as mpl import matplotlib.pyplot as pyplot mpl.rcParams['text.usetex'] = True mpl.rcParams['text.latex.preamble'] = [r'\usepackage{amsma

我想将matplotlib散点图导出为SVG,每个散点具有不同的超链接,这些散点不是简单的标记,而是Unicode字符

我尝试了以下方法:

import matplotlib.cm as cm
import matplotlib as mpl
import matplotlib.pyplot as pyplot
mpl.rcParams['text.usetex'] = True
mpl.rcParams['text.latex.preamble'] = [r'\usepackage{amsmath}'] #for \text command

f = pyplot.figure()
stemp='6F22'
markerstring=r'$\\unichar{"%s}$' % stemp
print(markerstring)
ss = pyplot.scatter([1, 2, 3], [4, 5, 6],color='black',s=[100, 0, 0],alpha=0.5, marker=markerstring)
ss.set_urls(['http://www.bbc.co.uk/news', 'http://www.google.com', None])
f.savefig('scatter.svg')
  • 它崩溃是因为“\u”或“\unichar”未知

  • 或显示6F22而不是漢 在最后的SVG中


您使用的字体是否具有该字符?您是否确保在最终SVG中加载字体?好问题。我想是的。我已经成功地用这个汉字显示标题或标签。因此,我很确定默认字体不是问题所在。