0

The following is an extension of a previous question. Am I wrong to assume that only some utf-8 characters are supported in matplotlib, at least with DejaVu Sans as suggested here, but not others? Specifically, the ballot x mark does not render, nor does the regular checkmark if I do not use the special mathtext syntax.

# -*- coding: utf-8 -*-
%pylab inline
import numpy as np
from matplotlib import rcParams
import matplotlib.pyplot as plt
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)

rcParams['font.family'] = 'sans-serif'
rcParams['font.sans-serif'] = ['DejaVu Sans']

plt.plot(t,s)
plt.text(1, -0.4, ur'$\u2718$', fontsize=20) # ballot x mark with mathtext
plt.text(1, -0.6, u'\u2713', fontsize=20) # check mark
plt.text(1, -0.8, ur'$\u2713$', fontsize=20) # check mark with mathtext
plt.xlabel(u'technologie\u00ebn in \u00b0C \u2713') # check mark after degrees C
plt.ylabel('volts (mV)')
plt.show()

yields

enter image description here

Community
  • 1
  • 1
phil0stine
  • 303
  • 1
  • 13
  • what version of matplotlib are you using? I'm using 2.0.0 and all characters seem to be supported. – Pablo Reyes Feb 04 '17 at 05:03
  • Works correctly for me with matplotlib 1.5.3. Are you sure that the DejaVu Sans font is installed? If so, try deleting your matplotlib font list cache in "~/.cache/matplotlib/". – u55 Feb 04 '17 at 05:14
  • I am on 1.4.2, that is probably the problem. I am using Python 2.7.10 (I know, but at the moment its necessary), OS X 10.11, Ipython 5.2.2 – phil0stine Feb 04 '17 at 05:42
  • Getting to 2.0.0 did in fact solve it. I think I was actually not upgrading correctly with pip due to caching. – phil0stine Feb 04 '17 at 06:35

0 Answers0