From 5f54543687f99c82d3ff660d011ef4e0c6cf819c Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 14 Mar 2017 16:51:59 -0400 Subject: [PATCH] FIX: do not skip isolated points in vector outputs Fixed bug in path interaction code where multiple moves in a row (which correspond to isolated points surrounded by nans after they have been filtered from the path) would be discarded which resulted in points not being plotted. closes #7293 --- .../baseline_images/test_path/nan_path.eps | 455 ++++++++++++++++++ .../baseline_images/test_path/nan_path.pdf | Bin 0 -> 2350 bytes .../baseline_images/test_path/nan_path.png | Bin 0 -> 7789 bytes .../baseline_images/test_path/nan_path.svg | 222 +++++++++ lib/matplotlib/tests/test_path.py | 13 + src/path_converters.h | 23 + 6 files changed, 713 insertions(+) create mode 100644 lib/matplotlib/tests/baseline_images/test_path/nan_path.eps create mode 100644 lib/matplotlib/tests/baseline_images/test_path/nan_path.pdf create mode 100644 lib/matplotlib/tests/baseline_images/test_path/nan_path.png create mode 100644 lib/matplotlib/tests/baseline_images/test_path/nan_path.svg diff --git a/lib/matplotlib/tests/baseline_images/test_path/nan_path.eps b/lib/matplotlib/tests/baseline_images/test_path/nan_path.eps new file mode 100644 index 000000000000..48d473aa3f09 --- /dev/null +++ b/lib/matplotlib/tests/baseline_images/test_path/nan_path.eps @@ -0,0 +1,455 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: /home/tcaswell/source/p/matplotlib/result_images/test_path/nan_path.eps +%%Creator: matplotlib version 2.0.0.post99.dev0+gcdc493d33, http://matplotlib.org/ +%%CreationDate: Tue Mar 14 16:50:24 2017 +%%Orientation: portrait +%%BoundingBox: 75 223 536 568 +%%EndComments +%%BeginProlog +/mpldict 7 dict def +mpldict begin +/m { moveto } bind def +/l { lineto } bind def +/r { rlineto } bind def +/c { curveto } bind def +/cl { closepath } bind def +/box { +m +1 index 0 r +0 exch r +neg 0 r +cl +} bind def +/clipbox { +box +clip +newpath +} bind def +end +%%EndProlog +mpldict begin +75.6 223.2 translate +460.8 345.6 0 0 clipbox +gsave +0 0 m +460.8 0 l +460.8 345.6 l +0 345.6 l +cl +1.000 setgray +fill +grestore +gsave +57.6 38.016 m +414.72 38.016 l +414.72 304.128 l +57.6 304.128 l +cl +1.000 setgray +fill +grestore +0.800 setlinewidth +1 setlinejoin +0 setlinecap +[] 0 setdash +0.000 setgray +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +0 -3.5 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +73.8327 38.016 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +0 -3.5 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +127.942 38.016 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +0 -3.5 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +182.051 38.016 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +0 -3.5 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +236.16 38.016 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +0 -3.5 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +290.269 38.016 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +0 -3.5 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +344.378 38.016 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +0 -3.5 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +398.487 38.016 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +-3.5 0 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +57.6 50.112 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +-3.5 0 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +57.6 90.432 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +-3.5 0 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +57.6 130.752 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +-3.5 0 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +57.6 171.072 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +-3.5 0 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +57.6 211.392 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +-3.5 0 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +57.6 251.712 o +grestore +gsave +/o { +gsave +newpath +translate +0.8 setlinewidth +1 setlinejoin +0 setlinecap +0 0 m +-3.5 0 l + +gsave +0.000 setgray +fill +grestore +stroke +grestore +} bind def +57.6 292.032 o +grestore +1.500 setlinewidth +2 setlinecap +0.122 0.467 0.706 setrgbcolor +gsave +357.1 266.1 57.6 38.02 clipbox +73.832727 50.112 m +182.050909 90.432 m +290.269091 130.752 m +344.378182 150.912 l +398.487273 171.072 l +stroke +grestore +1.000 setlinewidth +0 setlinecap +gsave +357.1 266.1 57.6 38.02 clipbox +/o { +gsave +newpath +translate +1.0 setlinewidth +1 setlinejoin +0 setlinecap +0 -3 m +0.795609 -3 1.55874 -2.683901 2.12132 -2.12132 c +2.683901 -1.55874 3 -0.795609 3 0 c +3 0.795609 2.683901 1.55874 2.12132 2.12132 c +1.55874 2.683901 0.795609 3 0 3 c +-0.795609 3 -1.55874 2.683901 -2.12132 2.12132 c +-2.683901 1.55874 -3 0.795609 -3 0 c +-3 -0.795609 -2.683901 -1.55874 -2.12132 -2.12132 c +-1.55874 -2.683901 -0.795609 -3 0 -3 c +cl + +gsave +0.122 0.467 0.706 setrgbcolor +fill +grestore +stroke +grestore +} bind def +73.8327 50.112 o +182.051 90.432 o +290.269 130.752 o +344.378 150.912 o +398.487 171.072 o +grestore +1.500 setlinewidth +2 setlinecap +1.000 0.498 0.055 setrgbcolor +gsave +357.1 266.1 57.6 38.02 clipbox +127.941818 191.232 m +236.16 231.552 m +290.269091 251.712 l +398.487273 292.032 m +stroke +grestore +1.000 setlinewidth +0 setlinecap +gsave +357.1 266.1 57.6 38.02 clipbox +/o { +gsave +newpath +translate +1.0 setlinewidth +1 setlinejoin +0 setlinecap +0 -3 m +0.795609 -3 1.55874 -2.683901 2.12132 -2.12132 c +2.683901 -1.55874 3 -0.795609 3 0 c +3 0.795609 2.683901 1.55874 2.12132 2.12132 c +1.55874 2.683901 0.795609 3 0 3 c +-0.795609 3 -1.55874 2.683901 -2.12132 2.12132 c +-2.683901 1.55874 -3 0.795609 -3 0 c +-3 -0.795609 -2.683901 -1.55874 -2.12132 -2.12132 c +-1.55874 -2.683901 -0.795609 -3 0 -3 c +cl + +gsave +1.000 0.498 0.055 setrgbcolor +fill +grestore +stroke +grestore +} bind def +127.942 191.232 o +236.16 231.552 o +290.269 251.712 o +398.487 292.032 o +grestore +0.800 setlinewidth +0 setlinejoin +2 setlinecap +[] 0 setdash +0.000 setgray +gsave +57.6 38.016 m +57.6 304.128 l +stroke +grestore +gsave +414.72 38.016 m +414.72 304.128 l +stroke +grestore +gsave +57.6 38.016 m +414.72 38.016 l +stroke +grestore +gsave +57.6 304.128 m +414.72 304.128 l +stroke +grestore + +end +showpage diff --git a/lib/matplotlib/tests/baseline_images/test_path/nan_path.pdf b/lib/matplotlib/tests/baseline_images/test_path/nan_path.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5734691b4e1ae9c62eea001cc2b8d26669b62862 GIT binary patch literal 2350 zcmd^BiBl726d$#=x`;<%s*DsrEC?uMce6Q&A__SG1;KzP$aJ$=AP}5ftfe4$6pvCBtvJ;VwpQh|j3{VrtpW;KtF|8W+Z>!a{R6t0WV3JI_ulV&`}@7O zo>2;wA1)9fo(Hdk0~H7kFu-V%k$?bz#$*_2fXYdZ)H8_yjUp3i6A(fNH3$quXoHq_ z^zXGm#TYn1SRBxWk(y+h;(*k8sZ8fWqB)YIfyiozA~}v`4M5CaB4~6Hsnr=0fy8!~ zWvFPH1FAhUXhu#DLVdTM07Mx!B6mNb}* zd@d>ju7ef@ou;E`bx1Ho3D6*efq`*i`+(-7+A)XIhD0t2;QWJ715~Bc!!p6M9@b7l zQ;e48cWdHUnoLE~cNNXMXc&)=INdho*-%l~cN-lCj~iCKx=uby8Ts{2Np7sipldB? zdGnSNy5#dEtJa9?Lnq35gAwuW|xclUi;FeG77r@YE}Q&Gt+MTfCDV$P`>rCzPO3#PrO zBd)E#=$5zDH^Vg{e9&#K;1uiYl5+EV8as4Jod=ZrV;mbAN6gC%maGyqsweODSaKmJ zL7&qqpSh>ueV3S&WA%$MXUE#{`;WM^<~N02@SU}8$L*mTbbon03!GkvUn;<=0xM_A zFRaghhs;?Ge!iRH^BIV{Ls2;t4GL{*4Q<45wEEB&Y!~^iE6UxdzLn;%v+Z12$MbXdpCC`JT#lI^xvw;@KwkJDbXU!% zX7g?hv2J_*is~~Je;?m^_|cA=zJ zjcu-FEo;aAQh6ukrN*@@3(q&b+HfyBp;$VW57Z-}bT1Z2&9wYhUn(b;Dn!)MPq z_S>?$O|=!_>&M+`IO<*X#azFum(BhqSE`K^mv_Xuxc=(h^unF@B+Z}A_~-BGZ@A1;24pA=HD?^+C#KD&${_1}(J! literal 0 HcmV?d00001 diff --git a/lib/matplotlib/tests/baseline_images/test_path/nan_path.png b/lib/matplotlib/tests/baseline_images/test_path/nan_path.png new file mode 100644 index 0000000000000000000000000000000000000000..199059655446f3d2a2cf3481812256d96d92447f GIT binary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000..e75b5341d4bc --- /dev/null +++ b/lib/matplotlib/tests/baseline_images/test_path/nan_path.svg @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/matplotlib/tests/test_path.py b/lib/matplotlib/tests/test_path.py index 6f1e57eed3d4..7964447b9fea 100644 --- a/lib/matplotlib/tests/test_path.py +++ b/lib/matplotlib/tests/test_path.py @@ -117,6 +117,19 @@ def test_marker_paths_pdf(): plt.ylim(-1, 7) +@image_comparison(baseline_images=['nan_path'], style='default', + remove_text=True, extensions=['pdf', 'svg', 'eps', 'png']) +def test_nan_isolated_points(): + + y0 = [0, np.nan, 2, np.nan, 4, 5, 6] + y1 = [np.nan, 7, np.nan, 9, 10, np.nan, 12] + + fig, ax = plt.subplots() + + ax.plot(y0, '-o') + ax.plot(y1, '-o') + + def test_path_no_doubled_point_in_to_polygon(): hand = np.array( [[1.64516129, 1.16145833], diff --git a/src/path_converters.h b/src/path_converters.h index d19b17dc17ae..3150b18edd5b 100644 --- a/src/path_converters.h +++ b/src/path_converters.h @@ -343,6 +343,7 @@ class PathClipper : public EmbeddedQueue<3> unsigned vertex(double *x, double *y) { unsigned code; + bool emit_moveto = false; if (m_do_clipping) { /* This is the slow path where we actually do clipping */ @@ -352,6 +353,8 @@ class PathClipper : public EmbeddedQueue<3> } while ((code = m_source->vertex(x, y)) != agg::path_cmd_stop) { + emit_moveto = false; + switch (code) { case (agg::path_cmd_end_poly | agg::path_flags_close): if (m_has_init) { @@ -363,10 +366,30 @@ class PathClipper : public EmbeddedQueue<3> goto exit_loop; case agg::path_cmd_move_to: + + // was the last command a moveto (and we have + // seen at least one command ? + // if so, shove it in the queue if in clip box + if (m_moveto && m_has_init && + m_lastX >= m_cliprect.x1 && + m_lastX <= m_cliprect.x2 && + m_lastY >= m_cliprect.y1 && + m_lastY <= m_cliprect.y2) { + // push the last moveto onto the queue + queue_push(agg::path_cmd_move_to, m_lastX, m_lastY); + // flag that we need to emit it + emit_moveto = true; + } + // update the internal state for this moveto m_initX = m_lastX = *x; m_initY = m_lastY = *y; m_has_init = true; m_moveto = true; + // if the last command was moveto exit the loop to emit the code + if (emit_moveto) { + goto exit_loop; + } + // else, break and get the next point break; case agg::path_cmd_line_to: