I'm trying to save a figure as a png image, and am having weird behavior:
import numpy as np
import matplotlib.pyplot as plt
import os
if __name__ == "__main__":
a = np.random.random(100)
b = np.random.random(100)
plt.plot(a, 'k')
#the following line does not show up properly
plt.plot(b, 'r.')
#the following line will show up properly
#plt.plot(b, 'r', alpha = 0.5)
plt.savefig('test.png', dpi = 300)
os.system('open test.png')
when using the "red point" setting r.
, the data points do not show up. Replacing this with r
, they do show up. Saving as pdf
instead of png
, and they show up in all cases. Setting plt.show()
instead of plt.savefig(...)
, and they show up, but when saving from the gui, they vanish again.
Why are they not showing up in the .png setting?
PS-I'm using Python 2.7 with the Agg renderer on OS X Yosemite.