When I save the chart from matplotlib in png format, the font is different from the one saved in jpg. This is a weird behavior.

I executed the following code: When changing the extension to png, the fonts of the resulting image file change.
"""
Simple demo of a scatter plot.
"""
import numpy as np
import matplotlib.pyplot as plt
if __name__ == '__main__':
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N)) ** 2
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.savefig("C:\Temp\myfile.jpg")
plt.show()
Update (07/27/2015): Fixed using a different backend. Used wxagg. Now using agg, which did the trick.
Reene source
share