1

How can I make a grid of plots in Julia using Gadfly?

Lets say I have an array of plots p as an example

p=[plot(y=[1:10],x=[1:10]),plot(y=[1:10],x=[1:10]),plot(y=[1:10],x=[1:10])]

I want to put this in a 2x2 grid (note 3x1 and 1x3 are easy using vstack and hstack)

I see a gridstack function in the Compose package. This takes a matrix of canvases. So I could use this function if there was some way of making an 'empty' plot:

gridstack( reshape([[render(p[i]) for i in 1:3], render( ...empty plot...)],2,2))
bdeonovic
  • 4,130
  • 7
  • 40
  • 70

2 Answers2

3

Using canvas() to create an empty default canvas that can be used as placeholder should be the right way to do it.

gridstack( reshape([[render(p[i]) for I in 1:3], canvas()],2,2))
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
vchuravy
  • 1,208
  • 10
  • 22
2

Actually, it should be like this:

cs = reshape([Context[render(pl[i]) for i in 1:numrows],context()], iceil(numrows/2),2);
p = gridstack(cs)
monty
  • 31
  • 2