Jupyter笔记本中的Imagegrid [英] Imagegrid in Jupyter notebook

查看:165
本文介绍了Jupyter笔记本中的Imagegrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在跟踪 Imagegrid 上的matplotlib文档中的示例,我正在尝试从Jupyter笔记本中复制它:

I'm following an example from the matplotlib documentation on Imagegrid, and I'm trying to replicate it from within Jupyter notebook:

% matplotlib inline
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
import numpy as np

im = np.arange(100)
im.shape = 10, 10

fig = plt.figure(1, (4., 4.))
grid = ImageGrid(fig, 111,  # similar to subplot(111)
                 nrows_ncols=(2, 2),  # creates 2x2 grid of axes
                 axes_pad=0.1,  # pad between axes in inch.
                 )

for i in range(4):
    grid[i].imshow(im)  # The AxesGrid object work as a list of axes.


plt.show()

预期输出:

我得到的是什么

如您所见,我没有得到图像的网格.我在做什么错了?

I'm not getting the grid of images, as you can see. What am I doing wrong?

编辑 如果删除%matplotlib inline选项,我将得到此信息(cell[1]以证明我重新启动了内核):

EDIT If I remove the %matplotlib inline option, I just get this (it's cell[1] to prove I restarted my kernel):

未显示图.

我正在运行matplotlib版本3.0.0,使用conda list matplotlib检查,jupyter4.4.0,使用jupyter --version检查.在Windows 10上,Anaconda,python 3.6.

I'm running matplotlib version 3.0.0, checked with conda list matplotlib, jupyter is 4.4.0, checked with jupyter --version. On Windows 10, Anaconda, python 3.6.

推荐答案

这是带有以下内容的问题matplotlib 3.0.0 .现在,它已已修复,从而在即将到来的3.0.1中不会发生.错误修正版本.

This is an issue with matplotlib 3.0.0. This has now been fixed, such that it will not occur in the upcoming 3.0.1 bugfix release.

在此期间,您有两个选择.

In the meantime you have two options.

  1. 恢复为matplotlib 2.2.3
  2. 决定在使用%matplotlib inline时不裁剪图像.通过

  1. Revert to matplotlib 2.2.3
  2. Decide to not crop the images when using %matplotlib inline. Do so via

%config InlineBackend.print_figure_kwargs = {'bbox_inches':None}

在IPython或Jupyter中.

in IPython or Jupyter.

这篇关于Jupyter笔记本中的Imagegrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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