JuliaPy / JuliaPy/PyPlot.jl

add_callback fails on axis

Đang mở
#500 0 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ả

I'm trying to set up a callback that runs every time the user changes the zoom setting on an axis. Here's a demo in Python:
```python
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> ax.plot(np.random.rand(5))
[]
>>> def callback(artist):
... print('callback')
...
>>> ax.xaxis.add_callback(callback)
0
>>> plt.show()
callback
callback
```
and then if I click on the magnifying glass and zoom in, I get another `callback` exactly as expected.

However, here I get nothing:
```julia
julia> using PyPlot

julia> PyPlot.version
v"3.3.1"

julia> fig, ax = plt.subplots()
(Figure(PyObject ), PyObject )

julia> ax.plot(rand(5))
1-element Vector{PyCall.PyObject}:
PyObject

julia> called = [] # in case there are any task-switching concerns...
Any[]

julia> pushtime(args...) = push!(called, time()) # just log that we got called
pushtime (generic function with 1 method)

julia> ax.xaxis.add_callback(pushtime)
0
```
and `called` never gets populated no matter what I do.

Any suggestions? EDIT: true for both Julia 1.5.2 and Julia v"1.6.0-DEV.1187".

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 reproducing the Julia example with PyPlot and the ax.xaxis.add_callback entry point, then compare its behavior with the Python matplotlib example across the reported Julia versions. Done means the callback is invoked when the axis zoom setting changes, as shown by the called log being populated.

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
40/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.