Too many people ask about how to display the plot in Juno (or think it doesn't work). I agree there is a difference making the plot and displaying the plot. However, this difference will matter to users as they become more familiar with the package.
It makes more sense to start using the package and go "well what if I don't want the plots to display, and just save them?" and have this more advanced user search the documentation, than it is to not display the plot to a new user who just used plot(...). I think display by default better matches the line:
Intuitive. Start generating plots without reading volumes of documentation. Commands should "just work".
Edit
For those who are new to the discussion, the idea is that in Juno, the way to plot is:
using Plots
plot(rand(4,4))
gui()
The gui() command is not necessarily shown in the documentation (at least, it's in a special spot and it's only specifically needed when the script is ran in Juno), and many people have been posting issues saying Plots doesn't work in Juno for this very reason. My suggestion is to remove the need for the gui() command when using Juno to evaluate a script (i.e. act like the REPL).
I can't get behind this. Sorry. The recent comment regarding Atom is that
Atom should be treated like the REPL (i.e. Whenever Atom "shows" the Plots
object inline we should display the plot). However the current behavior is
(and IMO should always be) the default.
On Monday, August 8, 2016, Christopher Rackauckas [email protected]
wrote:
438 https://github.com/tbreloff/Plots.jl/pull/438
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/tbreloff/Plots.jl/issues/437#issuecomment-238354893,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA492o7sbBGp5sHT29BRZE0hpg8sznp_ks5qd4ingaJpZM4JfZvq
.
What about changing the behavior just for Atom?
@pfitzseb @MikeInnes
+1 for current behavior.
I take it plot returns some plot object by default, and show calls display on that object?
In which case I think @tbreloff's solution can work fine, and this is what Gadfly will do already for example. I realise plotting is inconvenient right now but that's due to lack of developer focus more than anything; once core features like the debugger are more complete, plotting will become a much bigger focus and I think we can have a _really_ nice story there.
@KristofferC you don't see it as a problem that the same question gets asked almost every day about why plots aren't showing in Juno? Sure a Juno-specific solution would be fine as well instead of changing the Plots.jl default. But I think there's an issue that the same question keeps showing up.
I also like it when windows don't pop up all of the sudden. One thing that annoys me about working with jupyter notebook over SSH is that I have to specify --no-browser or I will suddenly be confronted with a X-tunneled firefox window :)
The plan here is to figure out what is called when the results of a line are "shown" in Juno. Is it: Base.show(io, MIME"text/plain", plt)?? cc: @MikeInnes
Then when Atom is loaded, I'll connect that call instead to Base.display. @ChrisRackauckas I know this isn't the default you were hoping for, but it will then be consistent with the REPL experience.
Consistent with the REPL experience is actually what I was meaning. I'm just hoping that when people throw plot commands into the Juno console it shows a plot. It's odd behavior right now, and my change would've been a heavy-handed way to fix it.
Juno uses Media.jl for its display system so the method that's called is render(::Atom.Inline, plot). You can overload this to return a plot icon and display the plot as a side effect. It's not the philosophically ideal way to do it but it works for now and I'll be cleaning up the APIs for this stuff.
@MikeInnes Does this look right?
Atom.Media.render(::Atom.Inline, plt::Plot) = display(PlotsDisplay(), plt)
Almost, you just need to return something that Juno can display. Try Atom.icon("graph").
That doesn't seem to work... I think it's trying to show text/plain:
WARNING: _show is not defined for this backend. m=text/plain
I'm not sure what's going on there. That looks like part of the new display changes in 0.5 which I haven't played around with at all. If Gadfly is working on 0.5 now I'll give that a go to see if there's anything I need to iron out.
It's been throwing that error for awhile, but the plots still show with it (when using Plots.gui()). (On "Juno master")
That warning is a Plots warning @MikeInnes, but I wouldn't expect it to be called.
also... is there any way to turn off those "Julia Client - Internal Error" message boxes? I feel like one opens every second on average.
Are Atom and Media both checked out? The internal error suggests something's gone wrong in your setup. I'll be tagging everything this week so it may be easier to hold out.
I can't even load Atom after checking them out:
ERROR: LoadError: function connect does not accept keyword arguments
while loading /home/tom/.atom/packages/julia-client/script/boot.jl, in expression starting on line 35
Julia has stopped: 1, null
I guess I'll revisit this another time.
You have to checkout a bunch of packages. Just wait for the tags.
I take it Plots.jl still doesn't work in the Atom IDE?
You mean it still does and it always has? You just have had to use Plots.gui() to display the plot (or set show=true in the backend). This issue is for making Plots.gui() not necessary (in Atom).
(the writemime warning is just a red harring: it's just a warning and Plots still works in versions that have that. But people posted issues since they saw the warning and no plot, thinking that the warning was some error making the plot not exist. In actuality, the answer has always just been "use the gui() command". It has worked since at least January when Juno was still very much alpha, and now it works on v0.4.6, v0.5-rc, and v0.6. But the fact that people still think it doesn't work because of the necessary "gui()" call is why I opened this issue.)
Oh thanks. NOTE: this has been edited several times.
So I did use the gui() command but it didn't work in Atom's ink console.
I did get it to work in the script editor, though only for the pyplot backend.
But it opens a separate window. Is the desired behaviour not to have it open in Atom's plot pane?
gui() is just a Julia command, so it will work in the Julia console of Atom and the script editor, but not Atom's console (which is a Javascript console). To be clear, but the Julia console I mean the one from Packages -> Julia -> Open Console (they should really bring back the keyboard shortcut...). The following should open a plot (in a separate window):
using Plots
plot(rand(4,4))
gui()
It doesn't work with the plot pane right now. There was a version awhile ago that did, but I had Tom switch off that default (with an environment variable) but it no longer works. There were a lot of developments in Atom since Tom has taken a look at it, so I would highly suspect that it won't work.
However, after the debugger is done (i.e. the v0.5 release, and bug fixes), the Juno team is going to be working on the plot pane again (in conjunction with Tom, as you can see in this thread) and so it will be there, and then likely the environment variable will be flipped so that plotting in the plot pane will be default.
Thanks a lot for this. And sorry for my confusing writing - and the edits above.
The issue with the console (I meant the Julia console, or the Ink console as the Juno guys seem to call it) seemed to be in part that I was plotting to the default pyplotjs() backend.
Using the pyplot() backend both of them work, though using the separate window as described. I will look forward to the work on the plotting pane, that will be really useful. Thanks!
No problem. This is pretty confusing and information which is hidden/scattered around.
To use PlotlyJS in its own window, you have to do the install which is described here, i.e.
using Blink
Blink.AtomShell.install()
and then PlotlyJS will be able to make its own window. When the plot pane for this exists, that should be unnecessary, but it should still be clear in the backend page that this is required. I'll make a PR for the docs.
Actually the install process shouldn't be necessary within Juno (which is why it no longer happens by default). Blink is able to reuse Atom's electron in that case rather than downloading a new one.
@tbreloff The Juno packages got tagged, so it may be a good time to pick this back up.
Right now it's bugged. For example, take this:
using Plots
pyplot()
plot(rand(4,4))
This, when run in the script, has the message "julia-client: can't render undefined" and prints a huge thing to the console inside an tag (presumably the PyPlot image?). Then this
using Plots
plotly()
plot(rand(4,4))
says the same thing and prints the HTML to the console:
<script src="/home/crackauc/.julia/v0.5/Plots/src/backends/../../deps/plotly-latest.min.js"></script> <div id="f6a5212f-3d6f-4ff7-8b11-a93bcd9d0e15" style="width:600px;height:400px;"></div>
<script>
PLOT = document.getElementById('f6a5212f-3d6f-4ff7-8b11-a93bcd9d0e15');
Plotly.plot(PLOT, [{"yaxis":"y","y":[0.9229659980004477,0.9893530240346875,0.35651266597028997,0.1301108147170087],"showlegend":true,"name":"y1","type":"scatter","xaxis":"x","line":{"width":1,"dash":"solid","color":"rgba(0, 154, 250, 1.000)","shape":"linear"},"x":[1,2,3,4],"mode":"lines"},{"yaxis":"y","y":[0.401815439706549,0.8595564117543919,0.7606549582688165,0.17410304140485522],"showlegend":true,"name":"y2","type":"scatter","xaxis":"x","line":{"width":1,"dash":"solid","color":"rgba(227, 111, 71, 1.000)","shape":"linear"},"x":[1,2,3,4],"mode":"lines"},{"yaxis":"y","y":[0.43222888619766797,0.08278807483044504,0.6901065156343831,0.5084079037915246],"showlegend":true,"name":"y3","type":"scatter","xaxis":"x","line":{"width":1,"dash":"solid","color":"rgba(62, 164, 78, 1.000)","shape":"linear"},"x":[1,2,3,4],"mode":"lines"},{"yaxis":"y","y":[0.47991369026873976,0.7066708152302037,0.4853472450376013,0.9588658252993292],"showlegend":true,"name":"y4","type":"scatter","xaxis":"x","line":{"width":1,"dash":"solid","color":"rgba(195, 113, 210, 1.000)","shape":"linear"},"x":[1,2,3,4],"mode":"lines"}], {"yaxis":{"type":"-","titlefont":{"size":15,"color":"rgba(0, 0, 0, 1.000)","family":"Helvetica"},"title":"","tickfont":{"size":11,"color":"rgba(0, 0, 0, 1.000)","family":"Helvetica"},"tickmode":"array","showgrid":true,"tickvals":[0.25,0.5,0.75],"domain":[0.057305336832895896,0.9901574803149605],"ticktext":["0.25","0.50","0.75"],"zeroline":false,"linecolor":"rgba(0, 0, 0, 1.000)","tickcolor":"rgba(0, 0, 0, 1.000)","anchor":"x"},"annotations":[],"width":600,"plot_bgcolor":"rgba(255, 255, 255, 1.000)","showlegend":true,"legend":{"bgcolor":"rgba(255, 255, 255, 1.000)","font":{"size":11,"color":"rgba(0, 0, 0, 1.000)","family":"Helvetica"},"bordercolor":"rgba(0, 0, 0, 1.000)"},"xaxis":{"type":"-","titlefont":{"size":15,"color":"rgba(0, 0, 0, 1.000)","family":"Helvetica"},"title":"","tickfont":{"size":11,"color":"rgba(0, 0, 0, 1.000)","family":"Helvetica"},"tickmode":"array","showgrid":true,"tickvals":[1.0,1.5,2.0,2.5,3.0,3.5,4.0],"domain":[0.05905511811023622,0.9934383202099738],"ticktext":["1.0","1.5","2.0","2.5","3.0","3.5","4.0"],"zeroline":false,"linecolor":"rgba(0, 0, 0, 1.000)","tickcolor":"rgba(0, 0, 0, 1.000)","anchor":"y"},"paper_bgcolor":"rgba(255, 255, 255, 1.000)","height":400,"margin":{"r":0,"l":0,"b":0,"t":20}});
</script>
Putting either commands directly in the console stalls.
I think you need to setup Media.jl to put those into the appropriate GUIs somehow since it appears to be just sending the plot outputs to the console but not know how to handle it.
This should work well now on Julia 0.5, master branch. I'll close until someone convinces me otherwise
Works well for me. For completeness of the discussion, note that the behavior for Juno is now documented here: https://juliaplots.github.io/output/ . The plot pane is the default by an environment variable, and at any time one can use gui() to open up a separate window (i.e. if one needs interactivity, use gui() to get the native plotting window).
Hey,
I'm really new to Atom, Julia and programming in general, so I will already apologize for misunderstandings.
I tried to get the plot to run and get Error messages.
At first I tried to run the command which is on the Juno website (plot(y=cumsum(randn(1000)), Geom.line) ) and before that I run using Plots and when I try the gui() command I get no current plot/subplot. And it further says: in current at Plots/src/plot.jl:11 is the error but I cant figure out what that means.
This also happens when I try to run it in the julia-console and also when I use the example from above with using Plots,plot(rand(4,4)), gui()
I hope this question belongs here. Thank you for possible help.
It shouldn't be necessary to use the gui() function anymore, it should just work. Are you on Julia 0.5 and the most recent versions of juno and Plots?
One of the tricky things for newcomers to Julia is that there are many plotting packages, each with their different interfaces. The first command plot(y=cumsum(randn(1000)), Geom.line) is from Gadfly, and shouldn't work in Plots.
The other example
using Plots
plot(rand(4,4))
should work (it will draw lines rather than points, which may surprise some).
What is the full text of the error you are getting?
Thank you very much for your quick reply,
for language-julia I am on 0.8.0, julia-client is 0.5.6 and uber-juno on 0.1.1
I dont really know what the Plot version is I cant find Plot anywhere. When I try to run using Plot I get ArgumentError: Module Plot not found in current path. But when I want to get the package with Pkg.add("Plot") it says unkown package Plot with the error message:
unknown package Plot
in macro expansion at ./pkg/entry.jl:53 [inlined]
in (::Base.Pkg.Entry.##2#5{String,Base.Pkg.Types.VersionSet})() at ./task.jl:360
in sync_end() at ./task.jl:311
in macro expansion at ./task.jl:327 [inlined]
in add(::String, ::Base.Pkg.Types.VersionSet) at ./pkg/entry.jl:51
in (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}})() at ./pkg/dir.jl:31
in cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}}, ::String) at ./file.jl:59
in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N}) at ./pkg/dir.jl:31
in add(::String) at ./pkg/pkg.jl:100
in include_string(::String, ::String) at ./loading.jl:441
in eval(::Module, ::Any) at ./boot.jl:234
in (::Atom.##53#56)() at /home/stefan/.julia/v0.5/Atom/src/eval.jl:39
in withpath(::Atom.##53#56, ::Void) at /home/stefan/.julia/v0.5/CodeTools/src/utils.jl:30
in withpath(::Function, ::Void) at /home/stefan/.julia/v0.5/Atom/src/eval.jl:45
in macro expansion a...
Im sorry but I have no idea what is going on right now. Also with the Gadfly it does not work but maybe I am doing it the wrong way or so.
The package name is Plots, not Plot.
On Wednesday, October 5, 2016, TheFourSymbols [email protected]
wrote:
Thank you very much for your quick reply,
for language-julia I am on 0.8.0, julia-client is 0.5.6 and uber-juno on
0.1.1
I dont really know what the Plot version is I cant find Plot anywhere.
When I try to run using Plot I get ArgumentError: Module Plot not found in
current path. But when I want to get the package with Pkg.add("Plot") it
says unkown package Plot with the error message:unknown package Plot
in macro expansion at ./pkg/entry.jl:53 [inlined]
in (::Base.Pkg.Entry.##2#5{String,Base.Pkg.Types.VersionSet})() at ./task.jl:360
in sync_end() at ./task.jl:311
in macro expansion at ./task.jl:327 [inlined]
in add(::String, ::Base.Pkg.Types.VersionSet) at ./pkg/entry.jl:51
in (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}})() at ./pkg/dir.jl:31
in cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}}, ::String) at ./file.jl:59
in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N}) at ./pkg/dir.jl:31
in add(::String) at ./pkg/pkg.jl:100
in include_string(::String, ::String) at ./loading.jl:441
in eval(::Module, ::Any) at ./boot.jl:234
in (::Atom.##53#56)() at /home/stefan/.julia/v0.5/Atom/src/eval.jl:39
in withpath(::Atom.##53#56, ::Void) at /home/stefan/.julia/v0.5/CodeTools/src/utils.jl:30
in withpath(::Function, ::Void) at /home/stefan/.julia/v0.5/Atom/src/eval.jl:45
in macro expansion a...Im sorry but I have no idea what is going on right now. Also with the
Gadfly it does not work but maybe I am doing it the wrong way or so.—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/tbreloff/Plots.jl/issues/437#issuecomment-251664624,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA492tH9YljK63n3r1iAOn8wzpsYgge5ks5qw5zTgaJpZM4JfZvq
.
To get Gadfly working, try
Pkg.checkout("Gadfly") #just once, the first time you use this package
using Gadfly
plot(y=cumsum(randn(1000)), Geom.line)
Thank you so much, it worked with the checkout and now I get something for the plot(y=cumsum(randn(1000)), Geom.line) command.
Cheers
You should get Plots working as well, it is a lot more convenient and user-friendly IMHO! :smile:
I don't know why, but now I tried with using Plots and it worked :+1: yeah, thank you so much for your patience.
The worst programming bugs are usually caused by one wrong character ;)
I am getting an error similar to TheFourSymbols. I am on Juno for JuliaPro 0.6.0.1. When I execute the following command in the console:
using Plots
plot(rand(4,4))
I get :
Any[4]
PyObject
PyObject
PyObject
PyObject
and nothing in the Plot pane.
If I add"gui()" to the above commands, I get "
No current plot/subplot
in gui at Plots\src\output.jl:134
in current at Plots\srcplot.jl:15"
Can someone please tell me what I am doing wrong? Here is a screenshot:

That is something different. You should open a separate issue for that.
on PyPlot... (look at the value of plot)
Sorry, I opened another issue for it and it is now closed. I was using "Plots" and "PyPlots" package in the code and that interfered with my "plyplot()" command.
Most helpful comment
@KristofferC you don't see it as a problem that the same question gets asked almost every day about why plots aren't showing in Juno? Sure a Juno-specific solution would be fine as well instead of changing the Plots.jl default. But I think there's an issue that the same question keeps showing up.