JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
474 stars 87 forks source link

Use `nbagg` backend in `IJulia` #137

Open dpsanders opened 9 years ago

dpsanders commented 9 years ago

Starting with version 1.4.3 (I believe) of matplotlib, there is an nbagg backend which allows interactive manipulation of figures. EDIT: In IPython, this is available using %matplotlib notebook

Would it be possible to make this available? (At least, I have not worked out how to use it from IJulia.)

stevengj commented 9 years ago

Depends on stevengj/PyCall.jl#89

Gregstrq commented 6 years ago

@stevengj, I've looked through the code for nbagg backend. The only thing communicating to kernel is CommSocket class object, which is subtype of ipython's Comm class.

It seems that the similar functionality for the IJulia kernel is realised with Comm type and its methods. The solution I can think of is to create via PyCall NewComm class, which will store reference to IJulia Comm type and transmit python methods to Julia functions, defined for Comm type. Then somehow make the figure manager instantiate this NewComm class instead of CommSocket in this line.

What do you think about it? Is it possible to use PyCall to define Python Class which references Julia structures and uses Julia functions?

Also, I am not really sure how can one modify the behaviour of @pyimported PyClass (which is needed to correct figure manager method). If I were to modify some method of Class, I would think about doing PyClass[:some_method] = new_julia_func. Is it possible? Does it have something to do with monkey-patching you mention in stevengj/PyCall.jl#89?

stevengj commented 6 years ago

Is it possible to use PyCall to define Python Class which references Julia structures and uses Julia functions?

Yes.

If I were to modify some method of Class, I would think about doing PyClass[:some_method] = new_julia_func. Is it possible?

I think so. Or rather, I think you have to modify the instance and not the class. This is monkey patching.

marius311 commented 2 years ago

Is there any hope of someone reviving this? The widget stuff in mpl just keeps getting cooler (https://twitter.com/martinRenou/status/1440617060640247815) and I'd love to be able to use it from Julia.