Hello everyone,
first time poster here.
I’m running into problems when trying to save vegalite plots as pdf, or anything other than html for that matter. The following script exemplifies this quite well:
using VegaLite
using Plots
x = 1:40000
y = sin.(x/1000)
v = @vlplot(:line, x = x, y = y)
println("png vegalite")
@time save("test_vegalite.png", v) # 3.421519 seconds (3.21 M allocations: 85.575 MiB, 0.35% gc time)
println("pdf vegalite")
@time save("test_vegalite.pdf", v) # 3.412176 seconds (3.21 M allocations: 85.880 MiB, 0.12% gc time)
println("html vegalite")
@time save("test_vegalite.html", v) # 0.057578 seconds (320.46 k allocations: 24.777 MiB, 7.92% gc time)
u = plot(x, y,)
println("png plots")
@time savefig(u, "test_plots.png") # 0.049850 seconds (9.83 k allocations: 2.033 MiB)
println("pdf plots")
@time savefig(u, "test_plots.pdf") # 0.074213 seconds (9.83 k allocations: 2.205 MiB)e
println("html plots")
@time savefig(u, "test_plots.html") # 0.046458 seconds (14.27 k allocations: 2.860 MiB)
It seems that using the FileIO based save
function to save vegalite plots to disk is between one and two orders of magnitudes slower than Plots’ savefig
function.
As I am quite often running visualizations of grids (for instance for cellular automata) which by themselves are not the fastest to save to disk, or am running several dozens of plots in a row, these behavior in essence breaks vegalite for me.
I cannot remember it to behave like this when I used it back in March or so, so while I do not have definitive proof for it, my guess is that this is some new behavior.
I already opened an issue over in the vegalite repository about a month ago, but did not receive an answer yet, and because the issue is somewhat pressing, I’m trying my luck here.
Any hints on where to look for the culprit or what can be done about it are welcome. I really like vegalite as a package, if it were not for this one problem.
Thanks in advance
Update:
I decided to try one of the examples
using VegaLite, VegaDatasets, Profile
v = dataset("movies") |>
@vlplot(
:rect,
width=300, height=200,
x={:IMDB_Rating, bin={maxbins=60}},
y={:Rotten_Tomatoes_Rating, bin={maxbins=40}},
color="count()",
config={
range={
heatmap={
scheme="greenblue"
}
},
view={
stroke="transparent"
}
}
)
@time v |> save("test2.pdf") # 38.962789 seconds (4.06 M allocations: 111.058 MiB, 0.06% gc time)
which gave consistent timing results with the former, far in excess of what one might expect I’d say…
So still wandering around aimlessly here. The timings have not been obtained from the first run where the compile time would show, just to have this out of the way.