JuliaPy / JuliaPy/PythonPlot.jl

plots with missing and NaN data

Open
#54 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
85
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Missing and missing are first class types/values in Julia Base. PythonPlot should simply not plot missing data. It errors in PythonPlot.
```julia
julia> plot([1, missing, 2])
ERROR: Python: ValueError: setting an array element with a sequence.
```

Here is a type translation inspired by one that works for PyCall (https://github.com/JuliaPy/PyPlot.jl/issues/593):
```julia
using PythonPlot
using PythonCall

"Recast julia Arrays with missing as python masked arrays."
function PythonCall.Py(a::Array{Union{T,Missing},N}) where {T,N}
np = PythonCall.pyimport("numpy")
np.ma.masked_invalid(np.array(replace(a, missing => NaN)))
end

# test
plot([1,2,missing,4,5], marker="o")
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.