From 9792c9869347f701dfdf58cfd99fb2d26ae7ef22 Mon Sep 17 00:00:00 2001 From: Simon P de Szoeke Date: Mon, 9 Dec 2024 17:08:59 -0800 Subject: [PATCH] PyObject use numpy_ma.array to plot masked missings --- src/PyPlot.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PyPlot.jl b/src/PyPlot.jl index e80db2f..b6d21b3 100755 --- a/src/PyPlot.jl +++ b/src/PyPlot.jl @@ -310,6 +310,14 @@ function withfig(actions::Function, f::Figure; clear=true) return f end +########################################################################### +# 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 + ########################################################################### using LaTeXStrings