Save figures as pdf

I currently do that with a for loop and FileIO. Don’t know if it’s the best way. This is how I do it:

using VegaLite
using FileIO

# create empty array that will hold graph names
gpharr = []

# create graphs
graph1 = ... 
push!(gpharr, :graph1)

graph2 = ... 
push!(gpharr, :graph2)

# save graphs
for g in gpharr
    save(File(format"PDF", joinpath("graphs", string(g)*".pdf")), eval(g))
    println(string(g))
end

I find that saving is the most time consuming part.