bdeonovic
bdeonovic

Reputation: 4220

Grid of Plots in Julia

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))

Upvotes: 1

Views: 2105

Answers (2)

vchuravy
vchuravy

Reputation: 1238

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))

Upvotes: 3

monty
monty

Reputation: 31

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)

Upvotes: 2

Related Questions