From 2e4d552f4889a1b84de5f7abe35035ca9924af3c Mon Sep 17 00:00:00 2001
From: Michael Droettboom <mdboom@gmail.com>
Date: Tue, 21 Oct 2014 10:39:18 -0400
Subject: [PATCH 1/2] Fix drawing of markers with no stroke

---
 src/_backend_agg.h | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/_backend_agg.h b/src/_backend_agg.h
index 172fbfc5d1c1..96e90022c4ba 100644
--- a/src/_backend_agg.h
+++ b/src/_backend_agg.h
@@ -528,6 +528,7 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
     theRasterizer.reset();
     theRasterizer.reset_clipping();
     rendererBase.reset_clipping(true);
+    agg::rect_i marker_size(0x7FFFFFFF, 0x7FFFFFFF, -0x7FFFFFFF, -0x7FFFFFFF);
 
     agg::int8u staticFillCache[MARKER_CACHE_SIZE];
     agg::int8u staticStrokeCache[MARKER_CACHE_SIZE];
@@ -545,6 +546,10 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
                 fillCache = new agg::int8u[fillSize];
             }
             scanlines.serialize(fillCache);
+            marker_size = agg::rect_i(scanlines.min_x(),
+                                      scanlines.min_y(),
+                                      scanlines.max_x(),
+                                      scanlines.max_y());
         }
 
         stroke_t stroke(marker_path_curve);
@@ -559,6 +564,10 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
             strokeCache = new agg::int8u[strokeSize];
         }
         scanlines.serialize(strokeCache);
+        marker_size = agg::rect_i(std::min(marker_size.x1, scanlines.min_x()),
+                                  std::min(marker_size.y1, scanlines.min_y()),
+                                  std::max(marker_size.x2, scanlines.max_x()),
+                                  std::max(marker_size.y2, scanlines.max_y()));
 
         theRasterizer.reset_clipping();
         rendererBase.reset_clipping(true);
@@ -570,10 +579,10 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
         agg::serialized_scanlines_adaptor_aa8 sa;
         agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl;
 
-        agg::rect_d clipping_rect(-1.0 - scanlines.max_x(),
-                                  -1.0 - scanlines.max_y(),
-                                  1.0 + width - scanlines.min_x(),
-                                  1.0 + height - scanlines.min_y());
+        agg::rect_d clipping_rect(-1.0 - marker_size.x2,
+                                  -1.0 - marker_size.y2,
+                                  1.0 + width - marker_size.x1,
+                                  1.0 + height - marker_size.y1);
 
         if (has_clippath) {
             while (path_curve.vertex(&x, &y) != agg::path_cmd_stop) {

From 48573d7641ebca87722f1dd4c01ec9794d2e6d8a Mon Sep 17 00:00:00 2001
From: Michael Droettboom <mdboom@gmail.com>
Date: Tue, 21 Oct 2014 11:24:57 -0400
Subject: [PATCH 2/2] Improve marker_edge test for this case

---
 lib/matplotlib/tests/test_axes.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py
index bbd6d9faf47c..aad782d8b41d 100644
--- a/lib/matplotlib/tests/test_axes.py
+++ b/lib/matplotlib/tests/test_axes.py
@@ -957,7 +957,7 @@ def test_markevery_polar():
 
 
 @image_comparison(baseline_images=['marker_edges'],
-                  remove_text=True)
+                  remove_text=True, tol=3)
 def test_marker_edges():
     x = np.linspace(0, 1, 10)
     fig = plt.figure()