0

I want to export a matplotlib scatter plot as a SVG with a different hyperlink from each scatter points which are not simple markers but Unicode characters.

I've try the following:

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')
  • It either crashs because "\u" or "\unichar" is unknown

  • Or displays 6F22 instead of 漢 in the final SVG

pierebean
  • 1
  • 3
  • Does the font you're using have that character? Have you ensured that font is loaded in the final SVG? – Robert Longson Nov 09 '20 at 08:41
  • Good question. I think yes. I have successfully display titles or label with this chinese characters. Therefore, I'm quite sure the default font is not the problem. – pierebean Nov 09 '20 at 10:28

0 Answers0