Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Exporting figure as pdf using savefig() messes up axis background in OS X #1894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/users/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ The individual items of a collection may now have different alpha
values and be rendered correctly. This also fixes a bug where
collections were always filled in the PDF backend.

Multiple images on same axes are correctly transparent
------------------------------------------------------

When putting multiple images onto the same axes, the background color
of the axes will now show through correctly.

.. _whats-new-1-2:

new in matplotlib-1.2
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _draw_unsampled_image(self, renderer, gc):

fc = self.axes.patch.get_facecolor()
bg = mcolors.colorConverter.to_rgba(fc, 0)
im.set_bg( *bg)
im.set_bg(*bg)

# image input dimensions
im.reset_matrix()
Expand Down Expand Up @@ -1078,7 +1078,7 @@ def get_window_extent(self, renderer=None):

def contains(self, mouseevent):
"""Test whether the mouse event occured within the image."""
if callable(self._contains):
if callable(self._contains):
return self._contains(self, mouseevent)

if not self.get_visible():# or self.get_figure()._renderer is None:
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ def test_image_edges():

assert g != 100, 'Expected a non-green edge - but sadly, it was.'

@image_comparison(baseline_images=['image_composite_background'], remove_text=True)
def test_image_composite_background():
fig = plt.figure()
ax = fig.add_subplot(111)
arr = np.arange(12).reshape(4, 3)
ax.imshow(arr, extent=[0, 2, 15, 0])
ax.imshow(arr, extent=[4, 6, 15, 0])
ax.set_axis_bgcolor((1, 0, 0, 0.5))
ax.set_xlim([0, 12])

if __name__=='__main__':
import nose
Expand Down
2 changes: 1 addition & 1 deletion src/_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ _image_module::from_images(const Py::Tuple& args)
pixfmt pixf(*imo->rbufOut);
renderer_base rb(pixf);

rb.clear(agg::rgba(1, 1, 1, 1));
rb.clear(agg::rgba(0, 0, 0, 0));
for (size_t imnum = 0; imnum < N; imnum++)
{
tup = Py::Tuple(tups[imnum]);
Expand Down