【问题标题】:Increasing each subplot's size and adjusting their width, matplotlib [duplicate]增加每个子图的大小并调整它们的宽度,matplotlib [重复]
【发布时间】:2019-08-26 22:40:27
【问题描述】:

我有一个来自 sci-kit learn 的数据集,fetch_lfw_people。

import matplotlib.pyplot as plt
# plotting faces
fig, ax = plt.subplots(3,5)
# fig.subplots_adjust(wspace=2)

for enumerate_counter, axi in enumerate(ax.flat):
    axi.imshow(faces.images[enumerate_counter], cmap='bone')
    axi.set(xticks=[], yticks=[],xlabel=faces.target_names[faces.target[enumerate_counter]])

在尝试使用子图显示图像并使用正确名称标记每个图像时,我想增加每个图像的大小并将它们分开足够宽以使名称不会重叠。

我试过了

fig.subplots_adjust(wspace=2)

但是,这会将图像分开,因此名称不会重叠,但是图像会变小。

我能解决这个问题吗?

【问题讨论】:

    标签: python matplotlib scikit-learn


    【解决方案1】:

    我将给出一些示例,其中包含一些示例编号,可能会引导您朝着正确的方向前进:

    plt.figure(figsize=(20,10)) 
    

    fig, ax = plt.subplots(figsize=(20, 10))
    

    【讨论】:

    • 谢谢!哈哈 fig, ax = plt.subplots(3,5,figsize=(20,10)) 做到了这一点并且有效!
    • 很高兴听到这有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 1970-01-01
    • 2014-06-28
    • 1970-01-01
    • 1970-01-01
    • 2015-06-17
    相关资源
    最近更新 更多