Plot size() not affecting figure size?

I am not sure if I am doing something wrong, apparently that should work. The “size” function is not affecting the plot output size, in:

using PyPlot
x = [1,2]
y = x
plot(x,y)
size(10,200)
savefig("./test.png")

I tried also

savefig("./test.png",figsize=(10,200))
or
savefig("./test.png",width=10,height=200)

Without any result either.
Thank you for your help.

1 Like

I believe size(10, 200) simply calls size(x::Number, d), and returns 1 (as 10 is a scalar).

I haven’t really used PyPlot in Julia for a while other than through Plots.jl, but in Python I would do something like:

fig, ax = subplots(figsize=(10,10))
ax[:plot](rand(100))

Which does change the figure size for me. (Note that in 1.0 I think PyPlot has gained the ability to understand dot notation so you can possibly write ax.plot)

1 Like

Thank you. I was not aware that the reasonable choice was to use Plots. This works:

using Plots
x = [1,2]
y = x
plot(x,y)
plot!(size=(400,400))
savefig("test.pdf")
9 Likes