我可以在三角形中排列3个大小相同的子图吗?

 紫色咖啡调 发布于 2023-02-13 14:32

为了清楚起见,我将使用一个4x4网格来显示我想要的子图的位置和大小.计数如下:

1  2  3  4
5  6  7  8
9  10 11 12
13 14 15 16

我想将顶部图放置在2,3,6和7上.两个底部图分别是9,10,13,14和11,12,15,16.在Matlab中,您可以使用子图范围,但我相信这仅适用于单行配置.

我怎么能在matplotlib中这样做?我需要一个gridspec吗?那我怎么用呢?这些例子不足以理解我应该如何解决这个问题.

1 个回答
  • 使用subplot范围:

    img = imread('cameraman.tif');
    figure;
    subplot(4,4,[2 3 6 7]);imshow(img);
    subplot(4,4,[9 10 13 14]);imshow(img);
    subplot(4,4,[11 12 15 16]);imshow(img);
    

    结果是:


    matplotlib基于的解决方案subplot2grid

    import matplotlib.pyplot as plt
    plt.subplot2grid( (4,4), [0,1], 2, 2 )
    plt.plot( x1, y1 )
    plt.subplot2grid( (4,4), [2,0], 2, 2 )
    plt.plot( x2, y2 )
    plt.subplot2grid( (4,4), [2,2], 2, 2 )
    plt.plot( x2, y2 )
    

    给出以下结果:

    在此输入图像描述

    2023-02-13 14:35 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有