diff --git a/CHANGELOG b/CHANGELOG index 84439e639298..0e208c93b4d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,12 @@ an active colorable artist, such as an image, and just sets up the colormap to use from that point forward. - PI +2012-11-16 Added the funcction _get_rbga_face, which is identical to + _get_rbg_face except it return a (r,g,b,a) tuble, to line2D. + Modified Line2D.draw to use _get_rbga_face to get the markerface + color so that any alpha set by markerfacecolor will respected. + - Thomas Caswell + 2012-11-13 Add a symmetric log normalization class to colors.py. Also added some tests for the normalization class. Till Stensitzki diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 631885594a91..3e4c3888d16c 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -531,12 +531,12 @@ def draw(self, renderer): if self._marker: gc = renderer.new_gc() self._set_gc_clip(gc) - rgbFace = self._get_rgb_face() - rgbFaceAlt = self._get_rgb_face(alt=True) + rgbaFace = self._get_rgba_face() + rgbaFaceAlt = self._get_rgba_face(alt=True) edgecolor = self.get_markeredgecolor() if is_string_like(edgecolor) and edgecolor.lower() == 'none': gc.set_linewidth(0) - gc.set_foreground(rgbFace) + gc.set_foreground(rgbaFace) else: gc.set_foreground(edgecolor) gc.set_linewidth(self._markeredgewidth) @@ -574,16 +574,20 @@ def draw(self, renderer): marker_trans = marker_trans.scale(w) else: gc.set_linewidth(0) + if rgbaFace is not None: + gc.set_alpha(rgbaFace[3]) renderer.draw_markers( gc, marker_path, marker_trans, subsampled, affine.frozen(), - rgbFace) + rgbaFace) alt_marker_path = marker.get_alt_path() if alt_marker_path: + if rgbaFaceAlt is not None: + gc.set_alpha(rgbaFaceAlt[3]) alt_marker_trans = marker.get_alt_transform() alt_marker_trans = alt_marker_trans.scale(w) renderer.draw_markers( gc, alt_marker_path, alt_marker_trans, subsampled, - affine.frozen(), rgbFaceAlt) + affine.frozen(), rgbaFaceAlt) gc.restore() @@ -955,12 +959,20 @@ def update_from(self, other): def _get_rgb_face(self, alt=False): facecolor = self._get_markerfacecolor(alt=alt) - if is_string_like(facecolor) and facecolor.lower()=='none': + if is_string_like(facecolor) and facecolor.lower() == 'none': rgbFace = None else: rgbFace = colorConverter.to_rgb(facecolor) return rgbFace + def _get_rgba_face(self, alt=False): + facecolor = self._get_markerfacecolor(alt=alt) + if is_string_like(facecolor) and facecolor.lower() == 'none': + rgbaFace = None + else: + rgbaFace = colorConverter.to_rgba(facecolor) + return rgbaFace + # some aliases.... def set_aa(self, val): 'alias for set_antialiased' diff --git a/lib/matplotlib/tests/baseline_images/test_axes/translucent_markers.pdf b/lib/matplotlib/tests/baseline_images/test_axes/translucent_markers.pdf new file mode 100644 index 000000000000..1aab041a7d2e Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/translucent_markers.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/translucent_markers.png b/lib/matplotlib/tests/baseline_images/test_axes/translucent_markers.png new file mode 100644 index 000000000000..bd5086ae3484 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/translucent_markers.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/translucent_markers.svg b/lib/matplotlib/tests/baseline_images/test_axes/translucent_markers.svg new file mode 100644 index 000000000000..3ae2016d186c --- /dev/null +++ b/lib/matplotlib/tests/baseline_images/test_axes/translucent_markers.svg @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 79b8d19e3c05..f254e63a4d76 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -962,6 +962,7 @@ def test_transparent_markers(): ax = fig.add_subplot(111) ax.plot(data, 'D', mfc='none', markersize=100) + @cleanup def test_mollweide_forward_inverse_closure(): # test that the round-trip Mollweide forward->inverse transformation is an @@ -1005,6 +1006,17 @@ def test_mollweide_inverse_forward_closure(): # compare np.testing.assert_array_almost_equal(xy, xy2, 3) + +@image_comparison(baseline_images=['translucent_markers'], remove_text=True) +def test_translucent_markers(): + np.random.seed(0) + data = np.random.random(50) + + fig = plt.figure() + ax = fig.add_subplot(111) + ax.plot(data, 'D', mfc=[1, 0, 0, .5], markersize=100) + + if __name__=='__main__': import nose nose.runmodule(argv=['-s','--with-doctest'], exit=False)