I'm a bit new to matplotlib, and am having difficulty outputting image or pdf files of plots that include my axes when using a batch script. The relevant code is below: fig=plt.figure() ax=fig.add_axes([0.1,0.1,0.75,0.75]) ax.set_xlabel("Radius") ax.set_ylabel("Average density") ax.plot(nr,ravs,'k-') # plt.plot(nr,ravs) # plt.ylabel("Average density") # plt.xlabel("Radius") plt.savefig("outputs/diskgap/rl"+str(ng)+".jpg") nr is a NumPy array simply containing linearly-space radius values, and ravs is a standard 1D array containing average density values; you can replicate with fake data. ng is simply the loop counter. This is in a batch script to take data from a series of output folders, plot it, and save the plots, while doing a bit of analysis and outputting that as well. What I'm finding is that this produces output exactly as expected when run from within IDLE or an interactive iPython session, but when run as a batch script (in the terminal, typing 'python polardisk.py' to run the script), I get the following output: Plot with no axes or labels What I should be getting is: earlier plot saved from plt.show() I've tried fiddling with the add_axes or figure() parameters, such as alpha, transparency, frameon, visibility, edgecolor, linewidth, etc, all to no avail--I get the same result. My hunch is that perhaps the axes and labels are being drawn, but for whatever reason they're being drawn as white, rather than black. That's an issue I've had before in IDL. And here's the full script: from matplotlib import pyplot as plt from matplotlib import cm import numpy as np # First, load data from density file into a 2D numpy array plt.ioff() ng = 1 masses = [] d=1 while d<=20: masses.append(d*0.0001) d+=1 gaps=[] while ng <= 20: rho = np.fromfile("outputs/diskgap/gr"+str(ng)+"/gasdens1.dat").reshape(128,384) #or whatever your dimensions are--reshape is r,phi # Now we need 1D arrays of radii and angles corresponding to each row and column of rho nphi = np.linspace(-3.14159265358979323844,3.14159265358979323844,num=384) #1D array of phi values nr = np.linspace(0.4,2.5,num=128) #1D array of r values -- set to whatever radial span you used # Create our plot ax = plt.subplot(111,polar=True) ax.set_yticklabels([]) #Get rid of radii labels (optional) # Create polar image ctf = ax.contourf(nphi,nr,rho,256,cmap=cm.jet) #256 is the number of colors--using fewer will mean fewer contour levels, and cm.jet is just the colormap. # Make sure we have a central hole where we didn't have data, rather than drawing nonzero rmin down to center # This will also plot the polar image onto the plot. plt.ylim(0,2.5) #2.5 is just rmax, set to whatever you used # Add a colorbar (optional) #plt.colorbar(ctf) #Save the image, and you're done! plt.savefig("outputs/diskgap/gr"+str(ng)+".jpg",bbox_inches='tight') plt.savefig("outputs/diskgap/gr"+str(ng)+".pdf",bbox_inches='tight') print "Finished disk number "+str(ng)+"!" plt.close("all") ravs = [] d=0 while d<len(rho[:,0]): ravs.append(np.mean(rho[d,:])) d+=1 fig=plt.figure() ax=fig.add_axes([0.1,0.1,0.75,0.75]) ax.set_xlabel("Radius") ax.set_ylabel("Average density") ax.plot(nr,ravs,'k-') # plt.plot(nr,ravs) # plt.ylabel("Average density") # plt.xlabel("Radius") plt.savefig("outputs/diskgap/rl"+str(ng)+".jpg") fig=plt.figure() ax=fig.add_axes([0.1,0.1,0.75,0.75]) ax.set_xlabel("Radius") ax.set_ylabel("Average density") ax.plot(nr,ravs,'k-') # plt.plot(nr,ravs) # plt.ylabel("Average density") # plt.xlabel("Radius") plt.savefig("outputs/diskgap/rl"+str(ng)+".pdf",bbox_inches='tight') gaps.append(ravs[38]/ravs[100]) print "Finished analyzing radial profile and gap for set "+str(ng)+"!" plt.close("all") ng+=1 plt.plot(masses,gaps) plt.ylabel("Percent deficiency") plt.xlabel("Planet mass") plt.savefig("outputs/diskgap/gaps.jpg",bbox_inches='tight') plt.plot(masses,gaps) plt.ylabel("Percent deficiency") plt.xlabel("Planet mass") plt.savefig("outputs/diskgap/gaps.pdf",bbox_inches='tight') The script runs in the same directory as the data provided--both outputs/ and the script are in the same directory. Continue reading...