2

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.

Mike
  • 1,727
  • 3
  • 15
  • 25
  • 2
    Not reproducible on Ubuntu, python 2.7, matplotlib 1.4.2. Have you tried with a different backend? (see http://stackoverflow.com/a/31706568/4481445.) – Jean-Sébastien Aug 01 '15 at 03:29

0 Answers0