plotjuliagadfly

How to set figure size or plot size in a Gadfly plot (using Julia)?


I would like to set the width (and height) of my Gadfly plot to adjust the aspect ratio in a hstack plot.

Orginal plot:

using Gadfly
p1 = Gadfly.plot(x=[1,2], y=[3,4], Geom.line)

enter image description here

hstack plot (to be adjusted):

using Gadfly
p1 = Gadfly.plot(x=[1,2], y=[3,4], Geom.line)
hstack(p1, p1, p1)

enter image description here

Any suggestions on how to adjust the plot size / figure size?


Solution

  • In the Gadfly galleries, plots use set_default_plot_size(). Another option is e.g.:

    p = plot(...)
    draw(PNG(6inch, 3inch), p)
    

    see ?SVG, ?PDF, ?PNG for more info.