Starting with PlotlyJS, version 0.18, a plot has the default layout template, template= :plotly (as in your example). It cannot be changed by setting plot_bgcolor, but by setting another template.
I tried your code, thank you for that. But all I got was the plot window for a few second showing some kind of “building” animation using cubes. Then the plot window disappears.
If I run it line by line in the repl I get completely different behavior where it works then gets put back to the plot with background ( see below), this is very confusing to a noob.
What am I missing? your code makes sense to me.
REPL running line by line
IF I run it line by line in the repl I can “see” the plots after
and running this code I get the plot window for a few second showing some kind of “building” animation using cubes. Then the plot window disappears.
Usually, I’m running the plotly plots in a Jupyter Notebook, not in REPL. I tested the posted code in a single notebook cell. Even if I move display(fig) in the next cell, no fig is displayed after relayout!, and the fig preserves the template, plotly_white.
But there is a PlotlyJS issue concerning relayout!. If a figure is already displayed just after relayout, then running display(fig), too, the default template is reset. As I can remember a user pointed out this issue, here, but not on the PlotlyJS.jl repository, to be considered for fixing.
Hence no matter where you are running the code above, when you got the right plot, don’t continue with display(fig).
I’m running Julia 1.7.3 and PlotlyJS, v 0.18.8.
I am running julia Version 1.8.2 (2022-09-29)
and Plotlyjs PlotlyJS v0.18.10
not sure what to do now as your code makes sense to me. I think what is a little disturbing is that plotting with a transparent background seems to be something that is useful and should work out of the box.
so if @VivMendes gets different result AND you do as well then something is wrong my end. The issue is that I haven’t done anything to tweak Plotlyjs. I just installed the PKG.
Hi @1153dent, you have a point. I forgot about that annoying problem related to (outdated) packages that PlotlyJS needs to spit out the plots in VSCode or Atom. If I run my code in VSCode, I get what you got, plus a massive amount of garbage associated with WebSockets, WebIO, Mux, and Blink.
But if you use Pluto.jl and the package PlutoPlotly.jl (according to @disberd, there is no need to use PlotlyJS directly), you can get what you need. With the precious help of @empet, find below the code that will certainly work in Pluto. I advise you to avoid installing Pluto and PlotlyJS in the same environment because PlotlyJS will deprecate Pluto. If you install Pluto, you do not need to install PlotlyJS. Pluto will install the packages required for the job to be done.
begin
using PlutoPlotly
fig22 = Plot(randn(150), Layout(yaxis_visible = false , xaxis_visible = false))
relayout!(fig22, hovermode="x", template = "plotly_white")
p4 = PlutoPlot(fig22)
end
My pleasure. I have been in your shoes many times before. I know what it feels to be stuck with a small problem and have a lot of people in the Julia community pop up and take me out of the hook in a minute. By the way, I used Matlab for 25 years, and the mood was quite different there, as far as I can remember.
I’m a python man myself STRUGGLING to remember all my basic computer science Loving reading bogumils blogs REALLY helps me and julia for talented amateurs especially now he’s covering Pluto
thanks again for taking time out from your weekend, really helps people like me,