-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Milestone
Description
This issue appears to be similar to what eventually got resolved in #1894
If I save a pdf with a single image, grayscale colormap and a transparent background, the axes background does not remain transparent. It becomes a black background. If I deviate from any of those ingredients, then the background is transparent as specified.
Example:
import matplotlib.pyplot as plt
from numpy.random import rand
fig, ax = plt.subplots(nrows=3, ncols=1, sharex=True)
ax[0].imshow(rand(15,15), extent=[0, 2, 15, 0], \
cmap=plt.cm.gray, aspect='auto', interpolation='Nearest')
ax[1].imshow(rand(15,15), extent=[0, 2, 15, 0], \
cmap=plt.cm.rainbow, aspect='auto', interpolation='Nearest')
ax[2].imshow(rand(15,15), extent=[0, 2, 15, 0], \
cmap=plt.cm.gray, aspect='auto', interpolation='Nearest')
ax[2].imshow(rand(15,15), extent=[4, 6, 15, 0], \
cmap=plt.cm.gray, aspect='auto', interpolation='Nearest')
ax[-1].set_xlim([0, 8])
fig.savefig('transparent.pdf', format='PDF', transparent = True)
fig.savefig('opaque.pdf', format='PDF', transparent = False)
fig.savefig('transparent.png', format='PNG', transparent = True)
Here is 'transparent.pdf', with the black background on the first set of axes:
Here is 'opaque.pdf', which looks correct:
Here is 'transparent.png', which also looks correct:
In case it matters, I am on Mac OS X 10.8.5, Enthought Canopy Python 2.7.6, and Matplotlib 1.4.0