I have made plots in VegaLite. I want to display the plots alongside each other in a pluto notebook. The standard way to do this would be to combine the plots as below
Plots.plot(plot1, plot2, layout = (2,1))
but that does not work with VegaLite (the error is “Cannot convert VegaLite.VLSpec to series data for plotting”)
Anyone got any ideas? Is there a way to arrange Pluto cells alongside each other?
The code that illustrates the problem is below (TOML contents redacted for brevity):
# v0.20.4
using Markdown
using InteractiveUtils
# ╔═╡ b6eea494-c11b-11ef-2081-d91d6453fe0a
begin
using VegaLite
using Plots
using DataFrames
end
# ╔═╡ 10c903d1-2d5d-4a90-836a-966b01aa6e13
begin
x = collect(1:10)
y = x .^ 2
y2 = sqrt.(x)
end
# ╔═╡ 65712402-f526-44a1-af9c-329aee310ea0
function make_plot(x, y, lab)
dd = DataFrame(x = x, y = y)
p = dd |> VegaLite.@vlplot(
title = "chart $lab",
:line,
x={field="x"},
y={field="y"}
)
return p
end
# ╔═╡ 139ccb35-73e5-46f4-8bd0-1f9a71f16768
make_plot(x,y,"squared")
# ╔═╡ 0c320865-c5c3-483b-ad67-faccdd36b5df
Plots.plot(make_plot(x,y,"squared"), make_plot(x,y2,"sqrt"), layout = (2,1)) ```