There is no plot in the PNG file. The PDF file is fine.

Can you please see the code below and let me know why the png figure
comes out empty (it only contains the x-axis, does not contain the
scatterplot). The pdf file has no such problems.

I have tried saving another usual line plot in .png format and I had
no problems. Does this have to do with scatter plot and .png format?

Thank you.

The code

import matplotlib.pyplot as plt
import numpy

differences = numpy.random.uniform(-2,2,190)

bin_values = numpy.arange(-2,2.6,0.1)
hist, bins = numpy.histogram(differences, bins = bin_values)

fig1 = plt.figure()
fig1.set_figwidth(6)
fig1.set_figheight(3)
ax1 = fig1.add_axes([0.1, 0.3, 0.8, 0.9])
ax1.patch.set_facecolor('Linen')

for left, hist_val in zip(bins[:-1], hist):
    xvec = [left]*hist_val
    yvec = 0.05*numpy.arange(hist_val) + 0.1
    if len(xvec) > 0:
        ax1.scatter(xvec,yvec)

ax1.axvline(1.3, ymax=0.6, color='DarkGreen')

# The frame of the axes is referred to as
# spines in matplotlib
for i in ax1.spines.iteritems():
    if i[0] in ['top','right', 'left']:
        i[1].set_visible(False)
    print i

# Ticks only in bottom
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('none')
ax1.set_ylim(bottom=0,top=1.5)

fig1.savefig('trial_figure.png', facecolor='Linen')
fig1.savefig('trial_figure.pdf', facecolor='Linen')

2011/2/9 Curiouslearn <curiouslearn@...287...>

Can you please see the code below and let me know why the png figure
comes out empty (it only contains the x-axis, does not contain the
scatterplot). The pdf file has no such problems.

Seems like mpl is getting confused because of the rect argument of
add_axes. Note that bottom is 0.3 and height is 0.9 so bottom + heigt

1. Maybe different backends differs handling the overflow.

Does this change in line 12 fix your issue?:

ax1 = fig1.add_axes([0.1, 0.3, 0.8, 0.6])

Goyo

···

I have tried saving another usual line plot in .png format and I had
no problems. Does this have to do with scatter plot and .png format?

Thank you.

The code

import matplotlib.pyplot as plt
import numpy

differences = numpy.random.uniform(-2,2,190)

bin_values = numpy.arange(-2,2.6,0.1)
hist, bins = numpy.histogram(differences, bins = bin_values)

fig1 = plt.figure()
fig1.set_figwidth(6)
fig1.set_figheight(3)
ax1 = fig1.add_axes([0.1, 0.3, 0.8, 0.9])
ax1.patch.set_facecolor('Linen')

for left, hist_val in zip(bins[:-1], hist):
xvec = [left]*hist_val
yvec = 0.05*numpy.arange(hist_val) + 0.1
if len(xvec) > 0:
ax1.scatter(xvec,yvec)

ax1.axvline(1.3, ymax=0.6, color='DarkGreen')

# The frame of the axes is referred to as
# spines in matplotlib
for i in ax1.spines.iteritems():
if i[0] in ['top','right', 'left']:
i[1].set_visible(False)
print i

# Ticks only in bottom
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('none')
ax1.set_ylim(bottom=0,top=1.5)

fig1.savefig('trial_figure.png', facecolor='Linen')
fig1.savefig('trial_figure.pdf', facecolor='Linen')

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users