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
4646Internal Changes
4747~~~~~~~~~~~~~~~~
4848
49+ - Remove null values before plotting. (:pull: `8535 `).
50+ By `Jimmy Westling <https://github.com/illviljan >`_.
4951
5052.. _whats-new.2023.12.0 :
5153
Original file line number Diff line number Diff line change @@ -944,6 +944,12 @@ def newplotfunc(
944944 if plotfunc .__name__ == "scatter" :
945945 size_ = kwargs .pop ("_size" , markersize )
946946 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 )
947953 else :
948954 size_ = kwargs .pop ("_size" , linewidth )
949955 size_r = _LINEWIDTH_RANGE
Original file line number Diff line number Diff line change @@ -3372,3 +3372,16 @@ def test_plot1d_default_rcparams() -> None:
33723372 np .testing .assert_allclose (
33733373 ax .collections [0 ].get_edgecolor (), mpl .colors .to_rgba_array ("k" )
33743374 )
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