From d61ceda836aa8974afae753de4e1e9f6f10c5f74 Mon Sep 17 00:00:00 2001 From: Chahak Mehta Date: Thu, 15 Dec 2022 01:09:23 -0600 Subject: [PATCH 1/3] Use masked stack to preserve mask info --- lib/matplotlib/collections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 3a8e3bf6266b..29667ff13922 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -322,7 +322,7 @@ def _prepare_points(self): paths.append(mpath.Path(np.column_stack([xs, ys]), path.codes)) xs = self.convert_xunits(offsets[:, 0]) ys = self.convert_yunits(offsets[:, 1]) - offsets = np.column_stack([xs, ys]) + offsets = np.ma.column_stack([xs, ys]) if not transform.is_affine: paths = [transform.transform_path_non_affine(path) From 9001a20fb72e151d83fdda65dcb3357fb6bcf3bb Mon Sep 17 00:00:00 2001 From: Chahak Mehta Date: Thu, 15 Dec 2022 20:22:29 +0530 Subject: [PATCH 2/3] Add test to check offset masking in scatter --- lib/matplotlib/tests/test_collections.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/matplotlib/tests/test_collections.py b/lib/matplotlib/tests/test_collections.py index 5b0d64657b32..782df21c5985 100644 --- a/lib/matplotlib/tests/test_collections.py +++ b/lib/matplotlib/tests/test_collections.py @@ -1,5 +1,6 @@ import io from types import SimpleNamespace +from datetime import datetime import numpy as np from numpy.testing import assert_array_equal, assert_array_almost_equal @@ -1129,3 +1130,22 @@ def test_set_offset_units(): off0 = sc.get_offsets() sc.set_offsets(list(zip(y, d))) np.testing.assert_allclose(off0, sc.get_offsets()) + + +@image_comparison(baseline_images=["test_check_masked_offsets"], + extensions=["png"], remove_text=True, style="mpl20") +def test_check_masked_offsets(): + # Check if masked data is respected by scatter + # Ref: Issue #24545 + unmasked_x = [ + datetime(2022, 12, 15, 4, 49, 52), + datetime(2022, 12, 15, 4, 49, 53), + datetime(2022, 12, 15, 4, 49, 54), + datetime(2022, 12, 15, 4, 49, 55), + datetime(2022, 12, 15, 4, 49, 56), + ] + + masked_y = np.ma.array([1, 2, 3, 4, 5], mask=[0, 1, 1, 0, 0]) + + fig, ax = plt.subplots() + ax.scatter(unmasked_x, masked_y) From b62b679b0337149042f0acae4e5f552e653ffa17 Mon Sep 17 00:00:00 2001 From: Chahak Mehta Date: Thu, 15 Dec 2022 20:32:12 +0530 Subject: [PATCH 3/3] Add baseline image for test --- .../test_check_masked_offsets.png | Bin 0 -> 4078 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/matplotlib/tests/baseline_images/test_collections/test_check_masked_offsets.png diff --git a/lib/matplotlib/tests/baseline_images/test_collections/test_check_masked_offsets.png b/lib/matplotlib/tests/baseline_images/test_collections/test_check_masked_offsets.png new file mode 100644 index 0000000000000000000000000000000000000000..ebac9df75ddb4636def2c1dda3cf332210832d3a GIT binary patch literal 4078 zcmeH~Yfw{X8poe-5fBtgD^hgP)oB@5H(XpGAVj-Wk+#TM1wk%p5R4Fx1SJ>2T-+*M zYK7VDR$M?b)>*_r16kaJds0v%xWG^eQ3B>@1Xdy>5M#&%*ptreuH9*8_M^7_aORwO z-#PE~|2+TSQ}VmLF)Nn)EeC)Vv3quY2;jg2z@e_ou$Iul(Z|>;v0ztH!T!7>1x)hs zEQli)&~oz%aq6(5cd!e?eNBEmyAQ!>MX4`*eP30uSPnISHqeN3?4Ro578?C;0?`C)xhsYPVm_#y*I#JKs6Ls+t}X z<-9>%C!bx~P5vg+C2D;M;cOK?DcN<>VdXuR%L88dN2}_ed$;3svRl-~M(>n!yw}{x z0dX}!2A@uRZ;6ZY#@72b;<}3&;oX)`BC5=DQI$QpYvm$IDzZN?>4!-;|S%wlXpew9o7Tu z%HpRc`Wa)=6IX=DIPtof>BR%tUuWm~_C>R2#ibVl>P*i^rXyL+B+r?dIKq8JhPy8` zzmeV$!cw8O#@`Ku zXUgQ;OQocUGHw7U^^bc#KZGx@)9CfIsXqexUUN$m`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ad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy