Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPlot doesn't work with the plot pane #325

Closed
davidanthoff opened this issue Oct 26, 2017 · 12 comments
Closed

PyPlot doesn't work with the plot pane #325

davidanthoff opened this issue Oct 26, 2017 · 12 comments

Comments

@davidanthoff
Copy link
Member

No description provided.

@davidanthoff davidanthoff added this to the v0.8.0 milestone Oct 26, 2017
@davidanthoff
Copy link
Member Author

@stevengj I'm trying to figure out why something like plot(randn(10), randn(10)) doesn't just show up in the plot pane in VS Code when entered in the integrated REPL.

The plot does show up in the plot pane when I execute gcf(), that returns an instance of PyPlot.Figure. But the call to just plot seems to return

1-element Array{PyCall.PyObject,1}:
 PyObject <matplotlib.lines.Line2D object at 0x0000000024CCFBA8>

which doesn't hook into the standard multimedia display system, as far as I can tell.

Is that just how it is, or is there some way that we could get a simple call to plot to show something in the plot pane?

@davidanthoff davidanthoff modified the milestones: v0.8.0, v0.9.0 Nov 1, 2017
@davidanthoff
Copy link
Member Author

I'm also moving this to v0.9.0 because there is a workaround for now: just call gcf().

@stevengj
Copy link

stevengj commented Nov 2, 2017

PyPlot functions don't return a displayable object, they work by side effects. If you want to return a displayable figure, you can do withfig(figure()) do .... end or you can return gcf().

In IJulia, PyPlot pushes some hooks to display plots after a cell executes. I don't know if it is possible to do something similar with vscode?

@davidanthoff
Copy link
Member Author

We just run the normal julia REPL inside VS Code and push our display backend onto the multimedia stack, that is really all we do. So unless there is some generic solution for the basic julia REPL I think we shouldn't really add anything beyond that.

I think this sounds just like by design then. Thanks for clarifying!

@stevengj
Copy link

stevengj commented Nov 2, 2017

One alternative is to have PyPlot call redisplay(fig) as a side-effect of each plotting function, and have your display backend use redisplay to push the figure onto a queue to display. PyPlot used to do this, in fact, but was really fragile because it involved monkey-patching matplotlib, and it was difficult to get it to work properly with Interact as well.

@davidanthoff
Copy link
Member Author

Ah, I'll have to figure out redisplay and how that would map with the approach we are using, thanks for the pointer.

@davidanthoff davidanthoff modified the milestones: v0.9.0, v0.10.0 Nov 4, 2017
@davidanthoff davidanthoff modified the milestones: v0.10.0, Backlog Jan 6, 2018
@MartinOtter
Copy link

MartinOtter commented Jan 15, 2019

The approach with gcf() displays the plot inside vscode without plot-toolbar. Therefore, important functionality is not available (zoom, save plot in different formats etc.).

Note, when starting a Julia REPL in a cmd window under Windows 7, plot opens a separate window with a toolbar. With figure(..) different windows can be opened:

pyplot_figure_in_cmd

@stevengj
Copy link

If you do pygui(true) it should open in a separate window, if that's what you want. https://github.com/JuliaPy/PyPlot.jl#interactive-versus-julia-graphics

@MartinOtter
Copy link

If you do pygui(true) it should open in a separate window, if that's what you want. https://github.com/JuliaPy/PyPlot.jl#interactive-versus-julia-graphics

Thanks very much. Yes this works!!!

@frankwswang
Copy link

I got the same problem and fixed it following the introductions in this issue page. Thank you very much! However, now if I want PyPlot to show the plot with a plot-toolbar, I have to add another line of code pygui(true), yet I don't need to add it in a windows cmd based Julia REPL. It seems that I have to adjust my Julia code which uses PyPlot if I want to run it on vscode. I wonder do you consider this a temporary solution or a settled method?

@davidanthoff
Copy link
Member Author

I think we'll add something at some point to configure the plot pane, i.e. whether it is active at all. At that point you could just disable it in the settings.

@jebej
Copy link

jebej commented May 18, 2020

Does the plot pane actually work? Running display(gcf()) does not seem to work.

Edit: nevermind, just had to restart the editor.

@pfitzseb pfitzseb closed this as completed Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants