You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue when setting scatter color in separate method call #10381
For an application I am developing, I need to call ax.scatter then change the colors of the points after the fact. However, if the input x/y values contain NaN values, then setting the colors after the fact doesn't work properly. The following example:
The top right point should be all yellow. However it isn't, because in the scatter call, invalid values are removed, so when I try and set the colors with set_array, the color values are offset from the x/y values. In the final case, things work since the 'bad' values are masked from neither the offsets nor the colors.
Is there a way to achieve something along the lines of the middle example (setting the colors after the fact)
This is because we create the initial artist and strip out any points that have nan in them. The new colors will then be offset from where you think they should be.
attn @efiring as you have been working around this code recently.
I think that adding the requested functionality will require writing a subclass of PathCollection that can keep track of the original inputs, and can repeat the mask- and nan-filtering operation every time a relevant property is updated.
Do we actually need to filter out the nans (except for backcompatibility considerations)? Aren't the renderers supposed to be able to handle nan data to start with anyways?
Good question; maybe they all can. If so, taking advantage of that would require some substantial changes, I think, because we support masked arrays, and use them internally. Going 100% with nans for missing values implies always using floating point, and switching from .max to .nanmax etc.
Activity
tacaswell commentedon Feb 5, 2018
This is because we create the initial artist and strip out any points that have
nanin them. The new colors will then be offset from where you think they should be.attn @efiring as you have been working around this code recently.
efiring commentedon Feb 5, 2018
I think that adding the requested functionality will require writing a subclass of
PathCollectionthat can keep track of the original inputs, and can repeat the mask- and nan-filtering operation every time a relevant property is updated.anntzer commentedon Feb 6, 2018
Do we actually need to filter out the nans (except for backcompatibility considerations)? Aren't the renderers supposed to be able to handle nan data to start with anyways?
efiring commentedon Feb 7, 2018
Good question; maybe they all can. If so, taking advantage of that would require some substantial changes, I think, because we support masked arrays, and use them internally. Going 100% with nans for missing values implies always using floating point, and switching from
.maxto.nanmaxetc.Alternative approach; addresses matplotlib#10381
Alternative approach; addresses matplotlib#10381
Alternative approach; addresses matplotlib#10381
Alternative approach; addresses matplotlib#10381
efiring commentedon Apr 15, 2019
I think this is closed by #12422. If not, please reopen.