File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ Documentation
46
46
Internal Changes
47
47
~~~~~~~~~~~~~~~~
48
48
49
+ - Remove null values before plotting. (:pull: `8535 `).
50
+ By `Jimmy Westling <https://github.com/illviljan >`_.
49
51
50
52
.. _whats-new.2023.12.0 :
51
53
Original file line number Diff line number Diff line change @@ -944,6 +944,12 @@ def newplotfunc(
944
944
if plotfunc .__name__ == "scatter" :
945
945
size_ = kwargs .pop ("_size" , markersize )
946
946
size_r = _MARKERSIZE_RANGE
947
+
948
+ # Remove any nulls, .where(m, drop=True) doesn't work when m is
949
+ # a dask array, so load the array to memory.
950
+ # It will have to be loaded to memory at some point anyway:
951
+ darray = darray .load ()
952
+ darray = darray .where (darray .notnull (), drop = True )
947
953
else :
948
954
size_ = kwargs .pop ("_size" , linewidth )
949
955
size_r = _LINEWIDTH_RANGE
Original file line number Diff line number Diff line change @@ -3372,3 +3372,16 @@ def test_plot1d_default_rcparams() -> None:
3372
3372
np .testing .assert_allclose (
3373
3373
ax .collections [0 ].get_edgecolor (), mpl .colors .to_rgba_array ("k" )
3374
3374
)
3375
+
3376
+
3377
+ @requires_matplotlib
3378
+ def test_plot1d_filtered_nulls () -> None :
3379
+ ds = xr .tutorial .scatter_example_dataset (seed = 42 )
3380
+ y = ds .y .where (ds .y > 0.2 )
3381
+ expected = y .notnull ().sum ().item ()
3382
+
3383
+ with figure_context ():
3384
+ pc = y .plot .scatter ()
3385
+ actual = pc .get_offsets ().shape [0 ]
3386
+
3387
+ assert expected == actual
You can’t perform that action at this time.
0 commit comments