@disberd This is a remarkable small piece of code. You have nailed it: PlotlyJS working without any problem at all inside Pluto notebooks. Moreover, we can have the plot displayed within Pluto’s window, or we can export it as an HTML file.
I tested your example and I just added some new cells where I experimented with different types of plots (2D, 3D, etc.). They all worked in an immaculate way. We can save the plots in html, png, pdf, svg formats. The only thing that I had to change is the name of the plot function: in VSCode we plot with plot()
, in your approach we have to start it with a capital letter Plot()
.
I tried this piece of code (typical PlotlyJS syntax):
begin
n = 200
r = LinRange(1e-4,10,n)
k = LinRange(0,2π,n)
g = r * cos.(k)'
f = r * sin.(k)'
z = (g.^2 .* f.^2) ./ (g.^4 + f.^4)
#p5 = Plot(surface(x=g,y=f,z=z),Layout(width=700,height=500))
p5 = Plot(surface(x=g,y=f,z=z))
end
and it took just 2.5ms to get the plot below (while it takes 4s in Jupyter!!!). In case someone has doubts, here it is:
Congrats. Wonderful job.