Plot3d: how to set size of graph, or size of GIF file generated from one

Out of the answer I got from How to create an animation based on t, x, y and z data? - #6 by fusion809 I’ve now got Julia code that works in generating a 3D animation of chaotic attractors, like the Rossler Attractor. The problem is the resolution. Presently the resolution of the generated GIF is fairly low, and I’d like a HD GIF (1920x1080). This is the code I have been trying:

# define the Rossler attractor
using Plots;
mutable struct Rossler
    dt; a; b; c; x; y; z
end

function step!(l::Rossler)
    dx = -l.y-l.z              ; l.x += l.dt * dx
    dy = l.x + l.a*l.y         ; l.y += l.dt * dy
    dz = l.b+l.z*(l.x-l.c)     ; l.z += l.dt * dz
end

attractor = Rossler((dt = 0.1, a = 0.2, b = 0.2, c = 14, x = 1., y = 1., z = 1.)...)


# initialize a 3D plot with 1 empty series
plt = plot3d(1, xlim=(-25,25), ylim=(-25,25), zlim=(0,90),
                title = "Rossler Attractor", marker = 2, 
                xlabel="x", ylabel="y", zlabel="z",
                size="(1920, 1080)",
                label="")

# build an animated gif by pushing new points to the plot, saving every 10th frame
@gif for i=1:20000
    step!(attractor)
    push!(plt, attractor.x, attractor.y, attractor.z)
end every 10

Before adding the size= field in plot3d this code ran fine, aside from producing a low-res GIF. Since adding it (and I assumed this would do what I want based on the plotting attributes page and the fact it mentions a size= argument of the format I used) I’m now getting the error:

MethodError: no method matching *(::Char, ::Measures.Length{:mm,Float64})
Closest candidates are:
  *(::Any, ::Any, !Matched::Any, !Matched::Any...) at operators.jl:502
  *(::Union{AbstractChar, AbstractString}, !Matched::Union{AbstractChar, AbstractString}...) at strings/basic.jl:229
  *(!Matched::Number, ::Measures.Measure) at /home/fusion809/.julia/packages/Measures/eNttC/src/operations.jl:48
  ...

Stacktrace:
 [1] prepare_output(::Plots.Plot{Plots.GRBackend}) at /home/fusion809/.julia/packages/Plots/oiirH/src/plot.jl:257
 [2] show(::IOStream, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.GRBackend}) at /home/fusion809/.julia/packages/Plots/oiirH/src/output.jl:197
 [3] png(::Plots.Plot{Plots.GRBackend}, ::String) at /home/fusion809/.julia/packages/Plots/oiirH/src/output.jl:8
 [4] frame(::Animation, ::Plots.Plot{Plots.GRBackend}) at /home/fusion809/.julia/packages/Plots/oiirH/src/animation.jl:20
 [5] frame(::Animation) at /home/fusion809/.julia/packages/Plots/oiirH/src/animation.jl:18
 [6] macro expansion at /home/fusion809/.julia/packages/Plots/oiirH/src/animation.jl:152 [inlined]
 [7] macro expansion at ./In[6]:30 [inlined]
 [8] macro expansion at /home/fusion809/.julia/packages/Plots/oiirH/src/animation.jl:163 [inlined]
 [9] top-level scope at ./In[6]:26 [inlined]
 [10] top-level scope at ./none:0

I haven’t the foggiest as to how I am meant to fix this error while still achieving what I want. Any ideas?

size needs a tuple, not a string. Try:

plt = plot3d(1, xlim=(-25,25), ylim=(-25,25), zlim=(0,90),
                title = "Rossler Attractor", marker = 2, 
                xlabel="x", ylabel="y", zlabel="z",
                size=(1920, 1080),
                label="")
1 Like

Any ideas why now the z label isn’t shown now (although, I still specify it as a plot3d argument)?

x and y labels are shown, albeit they’re quite small.