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

Skip to content

Commit 1ccf29d

Browse files
committed
Merge remote-tracking branch 'upstream/v1.2.x'
2 parents 23739dc + b9d3422 commit 1ccf29d

File tree

8 files changed

+291
-4
lines changed

8 files changed

+291
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ install:
1717
- 'if [ $TRAVIS_PYTHON_VERSION == "3.2" ]; then pip install https://github.com/y-p/numpy/archive/1.6.2_with_travis_fix.tar.gz; fi'
1818
- 'if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then pip install numpy; fi' # should be nop if pre-installed
1919
- if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then pip install --use-mirrors PIL; fi
20-
- sudo apt-get install inkscape
20+
- sudo apt-get update && sudo apt-get install inkscape
2121
- python setup.py install
2222

2323
script:

doc/users/whats_new.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ The individual items of a collection may now have different alpha
122122
values and be rendered correctly. This also fixes a bug where
123123
collections were always filled in the PDF backend.
124124

125+
Multiple images on same axes are correctly transparent
126+
------------------------------------------------------
127+
128+
When putting multiple images onto the same axes, the background color
129+
of the axes will now show through correctly.
130+
125131
.. _whats-new-1-2:
126132

127133
new in matplotlib-1.2

lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def _draw_unsampled_image(self, renderer, gc):
315315

316316
fc = self.axes.patch.get_facecolor()
317317
bg = mcolors.colorConverter.to_rgba(fc, 0)
318-
im.set_bg( *bg)
318+
im.set_bg(*bg)
319319

320320
# image input dimensions
321321
im.reset_matrix()
@@ -1078,7 +1078,7 @@ def get_window_extent(self, renderer=None):
10781078

10791079
def contains(self, mouseevent):
10801080
"""Test whether the mouse event occured within the image."""
1081-
if callable(self._contains):
1081+
if callable(self._contains):
10821082
return self._contains(self, mouseevent)
10831083

10841084
if not self.get_visible():# or self.get_figure()._renderer is None:
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_image/image_composite_background.svg

Lines changed: 272 additions & 0 deletions
Loading

lib/matplotlib/tests/test_image.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ def test_image_edges():
225225

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

228+
@image_comparison(baseline_images=['image_composite_background'], remove_text=True)
229+
def test_image_composite_background():
230+
fig = plt.figure()
231+
ax = fig.add_subplot(111)
232+
arr = np.arange(12).reshape(4, 3)
233+
ax.imshow(arr, extent=[0, 2, 15, 0])
234+
ax.imshow(arr, extent=[4, 6, 15, 0])
235+
ax.set_axis_bgcolor((1, 0, 0, 0.5))
236+
ax.set_xlim([0, 12])
228237

229238
if __name__=='__main__':
230239
import nose

src/_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ _image_module::from_images(const Py::Tuple& args)
816816
pixfmt pixf(*imo->rbufOut);
817817
renderer_base rb(pixf);
818818

819-
rb.clear(agg::rgba(1, 1, 1, 1));
819+
rb.clear(agg::rgba(0, 0, 0, 0));
820820
for (size_t imnum = 0; imnum < N; imnum++)
821821
{
822822
tup = Py::Tuple(tups[imnum]);

0 commit comments

Comments
 (0)