I am aware of how to save a plot when DISPLAY is undefined:
Generating a PNG with matplotlib when DISPLAY is undefined
But when I do this with UTF-8 characters in the plot, the characters are replaced by squares in the file. Here is an example of my code:
# -*- coding: utf-8 -*-
import matplotlib
matplotlib.use('Agg')
import matplotlib.pylab as plt
plt.plot(range(10))
plt.xlabel(u'وَبَوِّئْنا')
plt.savefig('test.jpg',format='jpg')
If the 'Agg' line is commented out, the output file looks fine when DISPLAY is defined. This has happened to me both on a Mac and with CentOS. Can someone please show me how to create a jpg with the UTF characters displayed correctly when DISPLAY is undefined?
Thank you in advance!