get_legend_handles_labels() for errorbar plot not working properly
- Lingua principale
- Julia
- Stelle
- 488
- Fork
- 90
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Related to https://github.com/JuliaPy/PyPlot.jl/issues/401.
I'm simply trying to reverse the order of the legend entries of two errorbar plots.
Pure python (from within Julia):
```julia
py"""
import matplotlib.pyplot as plt
import numpy as np
plt.errorbar(np.random.rand(10), np.random.rand(10), np.random.rand(10), label='first', marker='o', linestyle="")
plt.errorbar(np.random.rand(10), np.random.rand(10), np.random.rand(10), label='second', marker='o', linestyle="")
h,l = plt.gca().get_legend_handles_labels()
plt.legend(reversed(h),reversed(l), frameon=True)
"""
```

Using PyPlot:
```julia
errorbar(rand(10), rand(10), rand(10), label="first", marker="o", linestyle="")
errorbar(rand(10), rand(10), rand(10), label="second", marker="o", linestyle="")
h,l = gca().get_legend_handles_labels()
legend(reverse(h),reverse(l), frameon=true)
```

Note that the handles are wrong (should be markers with error bars).
PyPlot + ugly fix:
```julia
errorbar(rand(10), rand(10), 0.1 .* rand(10), marker="o", linestyle="none", label="first")
errorbar(rand(10), rand(10), 0.1 .* rand(10), marker="o", linestyle="none", label="second")
py"""
import matplotlib.pyplot as plt
h, l = plt.gca().get_legend_handles_labels()
plt.legend(reversed(h), reversed(l), frameon=True)
"""
```

Presumably a PyObject conversion issue? In python, `h` is a container
```python
[,
]
```
In Julia I find
```julia
2-element Array{Tuple{PyObject,Tuple{PyObject,PyObject},Tuple{PyObject}},1}:
(PyObject , (PyObject , PyObject ), (PyObject ,))
(PyObject , (PyObject , PyObject ), (PyObject ,))
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.