JuliaPy / JuliaPy/PythonPlot.jl

plots with missing and NaN data

未关闭
#54 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Julia
星标
85
派生
9
PR 合并指标
30 天内没有已合并 PR

描述

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")
```

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start with the Julia reproducer `plot([1, 2, missing, 4, 5], marker="o")` and inspect the PythonCall conversion path used by PythonPlot. Compare it with the proposed `PythonCall.Py` masked-array translation, then verify that plots containing `missing` no longer raise the shown ValueError and omit those values.

由索引模型根据 Issue 内容生成。

评估

技术栈
matplotlib, numpy, python
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。