Reputation: 838
I want to create a figure that contains multiple plots. However I want to be able to make each plot have a different size. For example, I want the first subplot to be approximately twice as wide as the second subplot. I was hoping to do something like this:
using PyPlot
a = rand(500,900)
b = rand(500,400) # notice how 'a' is 900 in width and 'b' is 400, i.e. 'a' is approximately twice as wide as 'b'
figure(1)
subplot(2,5,1:2) ; imshow(a)
subplot(2,5,3) ; imshow(b)
# and so on...
But this doesn't seem to work. Does anyone know of a method to allow me to adjust the size of each subplot?
Upvotes: 3
Views: 2710
Reputation: 22255
Similar to matlab, it is possible to have subplots of different sizes in the same figure window, as long as they don't overlap and they are defined in terms of a valid element in a valid grid. e.g.:
julia> subplot(2,2,1); imshow(a);
julia> subplot(2,4,3); imshow(b); # note the different grid size
However, if you want more precise control, then abandon the subplot command altogether, and manually draw your axes where you want them directly:
julia> axes([0.05, 0.55, 0.5, 0.4]); imshow(a);
julia> axes([0.6, 0.55, 0.35, 0.4]); imshow(b);
Upvotes: 3
Reputation: 5325
This kind of thing is much easier using Plots.jl
. See e.g. the @layout
command in one of the first examples in the documentation.
Upvotes: 1