julia PyPlot support missing data
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Domaine
- data-visualization
Piste de recherche
Commencez dans src/PyPlot.jl, autour des points d’entrée de plot aux lignes 190-194 indiquées dans la traceback, puis suivez la manière dont les valeurs Julia sont transmises à matplotlib via PyCall. Le travail est terminé lorsque plot([0, missing, 2]) ne déclenche plus l’erreur signalée, que les valeurs missing sont omises comme NaN et qu’un bref avertissement est émis.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Passing a value of missing, a first class type in Julia Base, to matplotlib should simply not the plot missing data. It should handle missing just like it presently does NaN.
However, passing a missing to matplotlib results in long and unhelpful errors from PyPlot and matplotlib:
plot([0,missing,2])
ERROR: PyError ($(Expr(:escape, :(ccall(#= ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'TypeError'>
TypeError("float() argument must be a string or a real number, not 'PyCall.jlwrap'")
File "mypath/python3.12/site-packages/matplotlib/pyplot.py", line 3794, in plot
return gca().plot(
^^^^^^^^^^^
File "/mypath/python3.12/site-packages/matplotlib/axes/_axes.py", line 1781, in plot
self.add_line(line)
File "/mypath/python3.12/site-packages/matplotlib/axes/_base.py", line 2339, in add_line
self._update_line_limits(line)
File "/mypath/python3.12/site-packages/matplotlib/axes/_base.py", line 2362, in _update_line_limits
path = line.get_path()
^^^^^^^^^^^^^^^
File "/mypath/python3.12/site-packages/matplotlib/lines.py", line 1037, in get_path
self.recache()
File "/mypath/python3.12/site-packages/matplotlib/lines.py", line 679, in recache
y = _to_unmasked_float_array(yconv).ravel()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mypath/python3.12/site-packages/matplotlib/cbook.py", line 1398, in _to_unmasked_float_array
return np.asarray(x, float)
^^^^^^^^^^^^^^^^^^^^
Stacktrace:
[1] pyerr_check
@ ~/.julia/packages/PyCall/1gn3u/src/exception.jl:75 [inlined]
[2] pyerr_check
@ ~/.julia/packages/PyCall/1gn3u/src/exception.jl:79 [inlined]
[3] _handle_error(msg::String)
@ PyCall ~/.julia/packages/PyCall/1gn3u/src/exception.jl:96
[4] macro expansion
@ ~/.julia/packages/PyCall/1gn3u/src/exception.jl:110 [inlined]
[5] #107
@ ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:43 [inlined]
[6] disable_sigint
@ ./c.jl:473 [inlined]
[7] __pycall!
@ ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:42 [inlined]
[8] _pycall!(ret::PyObject, o::PyObject, args::Tuple{Vector{Union{Missing, Int64}}}, nargs::Int64, kw::Ptr{Nothing})
@ PyCall ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:29
[9] _pycall!
@ ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:11 [inlined]
[10] pycall
@ ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:83 [inlined]
[11] plot(args::Vector{Union{Missing, Int64}}; kws::@Kwargs{})
@ PyPlot ~/.julia/packages/PyPlot/rWSdf/src/PyPlot.jl:194
[12] plot(args::Vector{Union{Missing, Int64}})
@ PyPlot ~/.julia/packages/PyPlot/rWSdf/src/PyPlot.jl:190
[13] top-level scope
@ REPL[56]:1
For years I have wrapped my inputs to matplotlib in the helper function
m2n(x) = ismissing(x) ? NaN : x
It is awkward.
I propose then, that
missingvalues are simply (not) plotted, just like NaNs.- a brief warning catch and warn the user of
missings in the data.
The proposed change will make PyPlot more compatible with Julia and Plots.jl, cf.
https://github.com/JuliaPlots/Plots.jl/issues/1706
I expect this will not break most cases, because missing is just a newer use pattern than NaN for missing data.
- Langage dominant
- Julia
- Étoiles
- 489
- Forks
- 90
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de JuliaPy/PyPlot.jl
-
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
-
colors has no field TwoSlopeNormOuverte
Difficulté 3/5 1-2 jours Accessibilité débutants 30/100
-
PGF preamble is not usedOuverte
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
-
Problem in using PyPlot in JuliaOuverte
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
-
violinplot not definedOuverte
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
Toutes les issues de JuliaPy/PyPlot.jl
Issues similaires
-
broken links in docsOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
JuliaPhysics/BeamletOptics.jl#127 ·
Les mainteneurs répondent en général sous 1 jour
-
Chains resumed from `initial_state` take `num_warmup + 1` warm-up stepsPeut-être pris @thevolatilebit l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
TuringLang/AbstractMCMC.jl#220 ·
-
found-by-agent
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
exanauts/SparseDirectSolver.jl#92 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour