matplotlib - 如何将多个 matshow() 结果放在一张图中?

标签 matplotlib matrix julia data-visualization

我正在尝试制作这样的图形。绘图矩阵,每个都是数值矩阵的可视化。

enter image description here

我认为代码应该如下所示:

使用 PyPlot

figure()
for i in 1:100
    subplot(10, 10, i)
    matshow(rand(10, 10))
end

但是这些图将独立地在新窗口中弹出,而不是在同一图形的不同部分中弹出。我做错了什么?

预先感谢您的宝贵时间!

最佳答案

免责声明:我对 Julia 毫无经验。因此,可能存在一些我不知道的警告。

来自matshow documentation :

matplotlib.pyplot.matshow(A, fignum=None, **kw)
Display an array as a matrix in a new figure window. [...]
fignum: [ None | integer | False ]
By default, matshow() creates a new figure window with automatic numbering. If fignum is given as an integer, the created figure will use this figure number. Because of how matshow() tries to set the figure aspect ratio to be the one of the array, if you provide the number of an already existing figure, strange things may happen. If fignum is False or 0, a new figure window will NOT be created.

因此,两种可能的选择可能是:

  • 使用fignum=false

    figure()
    for i in 1:100
        subplot(10, 10, i)
        matshow(rand(10, 10), fignum=false)
    end
    
  • 使用 imshow 而不是 matshow (因为 imshow 默认情况下不会创建新图形)

    figure()
    for i in 1:100
        subplot(10, 10, i)
        imshow(rand(10, 10))
    end
    

关于matplotlib - 如何将多个 matshow() 结果放在一张图中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46333342/

相关文章:

algorithm - 使用行索引和列索引一次查找矩阵中值的最小总和

julia - 以编程方式将参数传递给 @kwdef 结构

python - 如何将 x 轴标签添加到 seaborn 图形级图中的每个图

python - 插值时间序列,从x中选择y值

python - Numpy 向对角线添加值

exception - 如何在 Julia 中处理异常

function - Julia 中带参数的映射函数

python - 对于 Matplotlib 图,如何隐藏刻度线但保留刻度标签?

python - Matplotlib : How to save an animation after clicking on the button that launches the animation?

iphone - 使用 Accelerate (CLAPACK) 求解压缩列存储矩阵(在 xcode 中)?