Rene
Rene

Reputation: 41

Matplotlib shows different fonts when saving jpg with respect to png. Why?

When I save a plot from matplotlib with the png format, the font is different than when saved as jpg. This is strange behaviour. jpg image png image

I did run the following code: When changing the extension into 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 (27-07-2015): Fixed it using another backend. Did use wxagg. Now using agg which did the trick.

Upvotes: 4

Views: 449

Answers (1)

Rene
Rene

Reputation: 41

Fixed it using another backend. Did use wxagg. Now using agg which did the trick.

Upvotes: 0

Related Questions