matplotlib / ipympl

Matplotlib Jupyter Integration
https://matplotlib.org/ipympl/
BSD 3-Clause "New" or "Revised" License
1.59k stars 225 forks source link

Support for trait _view_count #481

Open bdch1234 opened 2 years ago

bdch1234 commented 2 years ago

The trait _view_count does not seem to populate on the canvas (always None). Is it not supported for ipympl?

ianhi commented 2 years ago

Interesting. I didn't know that the existed. I don't see a strong reason not to support it. Though it may be hard to keep track of when a view is no longer displayed?

@martinRenou do you have any thoughts on this?

I'd say my current position is that I would be happy to review a PR implementing this so that we can decide if there are any tradeoffs - but suspect that there's no harm in implementing this.

ianhi commented 2 years ago

oh wait, is all we have to set it equal to 0?

martinRenou commented 2 years ago

Thanks for opening an issue. I don't think this is specific to ipympl, it seems it has been added in ipywidgets in https://github.com/jupyter-widgets/ipywidgets/pull/1232.

oh wait, is all we have to set it equal to 0?

Probably, there is a check for it to be a number here.

I'd personally say that users of ipympl shouldn't need to access this property (after all it starts with an underscore).

But I actually didn't know this was a thing. We can probably use this to cleanup figures on the backend. What do you think @ianhi ?

bdch1234 commented 2 years ago

But I actually didn't know this was a thing. We can probably use this to cleanup figures on the backend. What do you think @ianhi ?

That’s exactly the use-case I was going for here, but it that would be possible to do directly in ipympl then it would be even better of course

martinRenou commented 2 years ago

Unfortunately such a logic would break if there are multiple clients.