JuliaPy / JuliaPy/PyPlot.jl

get_legend_handles_labels() for errorbar plot not working properly

Đang mở
#457 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Julia
Star
488
Fork
90
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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)
"""
```
![image](https://user-images.githubusercontent.com/187980/64120070-91211480-cd9b-11e9-8c82-24c8ee6feb72.png)

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)
```
![image](https://user-images.githubusercontent.com/187980/64120125-adbd4c80-cd9b-11e9-8634-5d9cfc393e3b.png)

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)
"""
```
![image](https://user-images.githubusercontent.com/187980/64120207-de04eb00-cd9b-11e9-880d-f23e5773e972.png)

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Start by running the Julia examples in the issue and inspect the get_legend_handles_labels() entry point and its PyObject conversion. Compare the returned errorbar handles with Python's ErrorbarContainer objects, then verify that reversing the handles preserves error bars in the legend.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
data-visualization
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.