-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
julia PyPlot support missing data #593
Comments
This would be nice to have. See also this issue here: One can also used masked arrays as shown in this example if one wants to avoid a promotion of integers to floats. |
Since I see this problem (JuliaPy/PyCall.jl) only when using PyPlot, adding the PyObject method is a PyPlot pull request. @Alexander-Barth's solution works inside the PyPlot module: using PyCall
using PyCall: PyObject
# extend PyObject to maskedarray to allow for plotting with missing values
function PyObject(a::Array{Union{T,Missing},N}) where {T,N}
numpy_ma = PyCall.pyimport("numpy").ma
pycall(numpy_ma.array, Any, coalesce.(a,zero(T)), mask=ismissing.(a))
end # test missing support
using PyPlot
x = [missing, 1, 2, 3, 4]
y = [1, 2, missing, 2, 3]
plot(x, y, marker=".") |
deszoeke
added a commit
to deszoeke/PyPlot.jl
that referenced
this issue
Dec 10, 2024
tests fix for JuliaPy#593
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Passing a value of
missing
, a first class type in Julia Base, to matplotlib should simply not the plotmissing
data. It should handlemissing
just like it presently does NaN.However, passing a
missing
to matplotlib results in long and unhelpful errors from PyPlot and matplotlib:For years I have wrapped my inputs to matplotlib in the helper function
It is awkward.
I propose then, that
missing
values are simply (not) plotted, just like NaNs.missing
s in the data.The proposed change will make PyPlot more compatible with Julia and Plots.jl, cf.
JuliaPlots/Plots.jl#1706
I expect this will not break most cases, because
missing
is just a newer use pattern than NaN for missing data.The text was updated successfully, but these errors were encountered: