I have a Pluto notebook with about 13 cells, most of which have a variable number of lines between the begin and end. When I take a look at the sum total of the time taken to execute each cell as reported by Pluto, it takes about 600 ms. The notebook was written fairly early on in my Julia programming experience, so is all written in the global scope. However 600 ms is acceptable.
The problem is that when I time the execution with a stopwatch, the time is about 30s. And it comes up with the message:
I can see which cell blocks update quickly and which ones don’t, but I don’t know why this message comes and why the time for update is much longer than that recorded by Pluto.
I’ve never seen that message in a Pluto notebook but it looks like the kind of message you get when JavaScript crashes and burns…I bet there are errors showing up in the console of the browser, but I’m not sure how much help they will be…?
julia> using Pluto
julia> Pluto.run()
[ Info: Loading...
┌ Info:
└ Opening http://localhost:1234/?secret=6QRRwPv8 in your default browser... ~ have fun!
┌ Info:
│ Press Ctrl+C in this terminal to stop Pluto
└
┌ Info: Removing compat entry for stdlib
└ p = "Statistics"
┌ Warning: The active manifest file has dependencies that were resolved with a different julia version (1.11.1). Unexpected behavior may occur.
└ @ C:\Users\jakez\AppData\Local\Temp\jl_BveW2q\Manifest.toml:0
┌ Info: Operation failed. Updating registries and trying again...
└ exception = Could not locate the source code for the StyledStrings package. Are you trying to use a manifest generated by a different version of Julia?
Updating registry at `C:\Users\jakez\.julia\registries\local_julia_registry`
Updating git-repo `https://github.com/Spectrum-Tec/local_julia_registry`
Updating registry at `C:\Users\jakez\.julia\registries\General.toml`
┌ Warning: Operation failed. Removing Manifest and trying again...
│ exception = Could not locate the source code for the StyledStrings package. Are you trying to use a manifest generated by a different version of Julia?
└ @ Pluto C:\Users\jakez\.julia\packages\Pluto\esC4R\src\packages\Packages.jl:496
This is after I ran Pkg.instantiate, Pkg.resolve, Pkg.update to try and coax it to play nice with 1.10.6 after using 1.11.1 for a while. Problem remained with both. I was wondering if I should remove the PlotlyJS dependency and see what happens. Thinking back the problem may have started when I switched from Plotly to PlotlyJS. I did that to get savefig() to work. I will experiment a bit more when I get a chance.
begin
#plotlyjs() # use for finding and annotating peaks
wavelength = 1.0 ./ stripsf[:,1] # spatial frequency converted to wavelength
i = findlast(x -> x >= 1, wavelength) + 1 # don't plot high wavelength data
abscissa = reverse(wavelength[i:end])
ordinate = reverse(sqrt.(averagef[i:end]./2.0))
plotCDf = Plots.plot(abscissa, ordinate,
title="CD $type Variation Frequency",
legend=false,
size=(600,375),
ylabel="$type [$unit]",
xlabel="CD wavelength [m]",
xlims=(0, 1))
threshold = 0.05
idx = findall(x -> x > threshold, ordinate)
#idx = [idx[1], idx[3], idx[5]]
#idx = idx[1:3]
for n in idx # perform annotation
annotate!(abscissa[n], ordinate[n], text("($(round(abscissa[n];digits=3)),
$(round(ordinate[n];digits=2)))", 10, :left))
end
figname = splitext(filename)[1] * "_avgSpectrum.png"
#Plots.savefig(plotCDf, figname)
plotCDf
#==#
end
When the default plots backend is used the last line plotCDf goes into an infinite loop or something, I never get control back. When the last line is commented out then the cell behaves normally.
begin
using PlutoPlotly
x = range(0, stop=6π, length=500)
y=sin.(x)
plot(x,y,title="Title", xlabel="freq", ylabel="Amp")
end
Outside of the notebook the title and labels plot correctly when I am using Plots. However the code as shown in the Pluto notebook displays the plot but not the title or text.
I gave PlutoPlotly.jl a try and it seems to work well except I have not figured out how to use the equivalent to the Plots command annotate!(). Or any mutating command for that matter.
PlutoPlotly.jl is based on and shares the synthax of PlotlyJS.jl and PlotlyBase.jl, which do not have a function with the same functionality as annotate! if not used from Plots.jl directly.
Adding annotations in a plot directly with PlotlyJS.jl requires putting the annotations inside a vector in the field annotations of the Layout object that you can optionally pass as second argument to the plot function.
Similarly, mutating commands should work as long as they are the ones defined in PlotlyBase.jl (mostly documented here, but beware that some of the mutating functions do not return the plot object itself and would not show the plot in Pluto if used as last command within a cell) and not the ones in Plots.jl.