Open tbreloff opened 8 years ago
FYI... this works for me:
using Atom, Plots
p = plot(rand(10))
Media.render(Atom.PlotPane(), Atom.div(Atom.d(), Atom.HTML(stringmime(MIME("text/html"), p))))
I think I figured it out on my own!
function setup_atom()
@require Atom begin
import Atom, Media
# connects the render function
Media.media(Plot, Media.Plot)
# Atom.displaysize(::AbstractPlot) = (535, 379)
# Atom.displaytitle(plt::AbstractPlot) = "Plots.jl (backend: $(backend(plt)))"
# this is like "display"... sends an html div with the plot to the PlotPane
function Media.render(pane::Atom.PlotPane, plt::Plot)
Media.render(pane, Atom.div(Atom.d(), Atom.HTML(stringmime(MIME("text/html"), plt))))
end
end
end
Any idea what the right methods are to set the size/title?
Great stuff! As a tip, you shouldn't need to have that @require
method inside setup_atom()
, since @require
will make sure that things are run at module init time anyway (although the current Requires.jl approach is something we want to move away from).
Size and title only apply to BlinkDisplay windows, and won't have an affect on Atom's PlotPane (although we could perhaps reuse displaytitle
here).
On Mar 13, 2016, at 11:50 AM, Mike J Innes notifications@github.com wrote:
Great stuff! As a tip, you shouldn't need to have that @require method inside setup_atom(), since @require will make sure that things are run at module init time anyway
I think that should be true, but it actually stopped working for me. I had code in Plots that required DataFrames, and it wasn't running unless I called it from init. I guess I need to open an issue in Requires.
(although the current Requires.jl approach is something we want to move away from).
Size and title only apply to BlinkDisplay windows, and won't have an affect on Atom's PlotPane (although we could perhaps reuse displaytitle here).
Ok it's not that important. Thanks.
— Reply to this email directly or view it on GitHub.
Hi @MikeInnes. I just started using Atom yesterday, and I was attempting to get Plots working with the PlotPane. I made an attempt at it, calling this method from
Plots.__init__
:but I end up with this error:
Any thoughts to debug it? It seems like one of the Atom packages is messing with eval internals, but it's kinda incomprehensible to me.
Side note... comments in the code would be much appreciated!