python - 增加每个子图的大小并调整它们的宽度,matplotlib
问题描述
我有一个来自 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)
但是,这会将图像分开,因此名称不会重叠,但是图像的尺寸会变小。
无论如何我可以解决这个问题吗?
解决方案
我将给出一些示例,其中包含一些示例编号,这些示例可能会引导您朝着正确的方向前进:
plt.figure(figsize=(20,10))
或者
fig, ax = plt.subplots(figsize=(20, 10))
推荐阅读
- python - 通过字典解析字符串
- php - Laravel LengthAwarePaginator where 查询
- haskell - 将负责从各种函子中提取值的代码放在哪里
- python - 用于清理文档的深度学习模型
- c# - 如果我设置数据上下文,则可见性属性不起作用,反之亦然
- javascript - 在模态中从选择中设置 PHP 变量
- php - Sonata Admin - 更改过滤器值(关系字段)
- eclipse - 如何在 Eclipse Luna 中将现有文件的编码转换为 UTF-8
- python - 如果我必须添加一个以 3 为间隔的值的系列,python 中的代码将是什么
- javascript - Visual Studio 和 chrome 的 let 和 const 问题