get_legend_handles_labels() for errorbar plot not working properly
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
首先執行 issue 中的 Julia 範例,並檢查 get_legend_handles_labels() 入口點及其 PyObject 轉換。將傳回的 errorbar 控點與 Python 的 ErrorbarContainer 物件進行比較,然後確認反轉這些控點後圖例中仍會保留誤差條。
由索引模型根據 Issue 內容生成。
描述
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):
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:
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:
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
[<ErrorbarContainer object of 3 artists>,
<ErrorbarContainer object of 3 artists>]
In Julia I find
2-element Array{Tuple{PyObject,Tuple{PyObject,PyObject},Tuple{PyObject}},1}:
(PyObject <matplotlib.lines.Line2D object at 0x000000006FAB9F98>, (PyObject <matplotlib.lines.Line2D object at 0x000000006FAD6780>, PyObject <matplotlib.lines.Line2D object at 0x000000006FAD6EF0>), (PyObject <matplotlib.collections.LineCollection object at 0x000000006FAD6320>,))
(PyObject <matplotlib.lines.Line2D object at 0x000000006FADF860>, (PyObject <matplotlib.lines.Line2D object at 0x000000006FADFB70>, PyObject <matplotlib.lines.Line2D object at 0x000000006FADFCC0>), (PyObject <matplotlib.collections.LineCollection object at 0x000000006FADF550>,))
- 主要語言
- Julia
- 星號
- 489
- 分支
- 89
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
JuliaPy/PyPlot.jl 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 45/100
-
julia PyPlot support missing data可能已有人在做 @deszoeke 於 687 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 45/100
-
難度 3/5 1-2 天 新手友好度 30/100
-
難度 3/5 1-2 天 新手友好度 35/100
-
難度 4/5 3-5 天 新手友好度 25/100
查看 JuliaPy/PyPlot.jl 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 61/100
-
難度 2/5 1-3 小時 新手友好度 83/100
-
bug
難度 2/5 1-3 小時 新手友好度 80/100
Deltares/Wflow.jl#1145 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
JuliaDiff/FiniteDiff.jl#238 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
JuliaDiff/SparseMatrixColorings.jl#356 ·
維護者通常 1 天內回覆