朱莉娅:如何使用PyPlot创建不同大小的子图? [英] Julia: How to create subplots with different sizes using PyPlot?

查看:213
本文介绍了朱莉娅:如何使用PyPlot创建不同大小的子图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个包含多个图的图形.但是我希望能够使每个地块具有不同的大小.例如,我希望第一个子图的宽度大约是第二个子图的两倍.我希望做这样的事情:

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?

推荐答案

类似于matlab,在同一图形窗口中可以有不同大小的子图,只要它们不重叠且以术语定义即可有效网格中的有效元素的数量.例如:

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

但是,如果要进行更精确的控制,则完全放弃subplot命令,并直接在所需轴上手动绘制轴:

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

这篇关于朱莉娅:如何使用PyPlot创建不同大小的子图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆