Unable to show legend in surface plot
- 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ả
Hi all,
i am getting the following error when i try to add a legend to an existing plot;
the code is the following:
`using PyPlot;`
`x=collect(linspace(0,1,100));`
`y=collect(linspace(0,2,20));`
`f(x,y)=sin.(x).*cos.(y);`
`g(x,y)=sin.(x).*sin.(y);`
`z1=[f(x_i,y_j) for x_i in x, y_j in y]`
`z2=[g(x_i,y_j) for x_i in x, y_j in y]`
`surf(x,y,z1')`
`surf(x,y,z2')`
`legend(["Function1","Function2"])`
When i try to execute this code in the julia REPL i have no error and the legend shows up;

but when i save the code in a script file and try to execute that through include("filename.jl") i am getting the following error and the legend does not show up:
ERROR: LoadError: PyError (ccall(@pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, arg, C_NULL))
AttributeError("'Poly3DCollection' object has no attribute '_edgecolors2d'",)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\pyplot.py", line 3744, in legend
ret = gca().legend(*args, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\axes\_axes.py", line 500, in legend
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\legend.py", line 697, in __init__
self._init_legend_box(handles, labels, markerfirst)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\legend.py", line 957, in _init_legend_box
fontsize, handlebox))
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\legend_handler.py", line 119, in legend_artist
fontsize, handlebox.get_transform())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\legend_handler.py", line 733, in create_artists
self.update_prop(p, orig_handle, legend)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\legend_handler.py", line 76, in update_prop
self._update_prop(legend_handle, orig_handle)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\legend_handler.py", line 716, in _update_prop
orig_handle.get_edgecolor())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\mpl_toolkits\mplot3d\art3d.py", line 706, in get_edgecolors
return self._edgecolors2d
Stacktrace:
[1] pyerr_check at C:\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\PyCall\src\exception.jl:56 [inlined]
[2] pyerr_check at C:\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\PyCall\src\exception.jl:61 [inlined]
[3] macro expansion at C:\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\PyCall\src\exception.jl:81 [inlined]
[4] #_pycall#67(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Array{String,1}, ::Vararg{Array{String,1},N} where N) at C:\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\PyCall\src\PyCall.jl:653 [5] _pycall(::PyCall.PyObject, ::Array{String,1}, ::Vararg{Array{String,1},N} where N) at C:\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\PyCall\src\PyCall.jl:641 [6] #pycall#71(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::Array{String,1}, ::Vararg{Array{String,1},N} where N) at C:\JuliaPro-0.6.
2.2\pkgs-0.6.2.2\v0.6\PyCall\src\PyCall.jl:675 [7] pycall(::PyCall.PyObject, ::Type{PyCall.PyAny}, ::Array{String,1}, ::Vararg{Array{String,1},N} where N) at C:\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\PyCall\src
\PyCall.jl:675 [8] #legend#72(::Array{Any,1}, ::Function, ::Array{String,1}, ::Vararg{Array{St
ring,1},N} where N) at C:\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\PyPlot\src\PyPlot.jl:172
[9] legend(::Array{String,1}, ::Vararg{Array{String,1},N} where N) at C:\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\PyPlot\src\PyPlot.jl:169 [10] include_from_node1(::String) at .\loading.jl:576
[11] include(::String) at .\sysimg.jl:14
while loading C:\Users\Administrator\Desktop\JuliaProjects\BrokenPyPlot.jl, in expression starting on line 13`
Do you have any idea?
Am I making some mistakes?
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
Chạy script Julia được cung cấp bằng include("filename.jl") và so sánh với hành vi của REPL. Bắt đầu từ PyPlot.legend trong stack trace và cách xử lý chú giải của matplotlib Poly3DCollection. Hoàn thành khi chú giải của biểu đồ bề mặt được kết xuất mà không có AttributeError _edgecolors2d khi được tải từ một script.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- julia, python
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 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
- 45/100