Python可视化:python+jupyter notebook展示图片或插入图片_如何在python notebook中展示图像-程序员宅基地

技术标签: python  Python可视化  Python配置  数据可视化  

Python可视化:python+jupyter notebook展示图片或插入图片

python+jupyter notebook展示图片或插入图片

有时候,在Jupyter notebook中,我们想要插入一些图片,就像下面的效果一样:
在这里插入图片描述
用到的模块主要是:IPython.display中的Image

from IPython.display import Image
width = 1000
height = 600
Image(filename = 'openstreetmap_figure/openstreetmap_window.jpg', width=width, height=height) 

这样就可实现上面的效果。

Image()函数的详细参数解释

下面是Image()函数的详细参数文档解释。

Image(
    data=None,
    url=None,
    filename=None,
    format=None,
    embed=None,
    width=None,
    height=None,
    retina=False,
    unconfined=False,
    metadata=None,
)
Docstring:      An object that wraps data to be displayed.
Init docstring:
Create a PNG/JPEG/GIF image object given raw data.

When this object is returned by an input cell or passed to the
display function, it will result in the image being displayed
in the frontend.

Parameters
----------
data : unicode, str or bytes
    The raw image data or a URL or filename to load the data from.
    This always results in embedded image data.
url : unicode
    A URL to download the data from. If you specify `url=`,
    the image data will not be embedded unless you also specify `embed=True`.
filename : unicode
    Path to a local file to load the data from.
    Images from a file are always embedded.
format : unicode
    The format of the image data (png/jpeg/jpg/gif). If a filename or URL is given
    for format will be inferred from the filename extension.
embed : bool
    Should the image data be embedded using a data URI (True) or be
    loaded using an <img> tag. Set this to True if you want the image
    to be viewable later with no internet connection in the notebook.

    Default is `True`, unless the keyword argument `url` is set, then
    default value is `False`.

    Note that QtConsole is not able to display images if `embed` is set to `False`
width : int
    Width in pixels to which to constrain the image in html
height : int
    Height in pixels to which to constrain the image in html
retina : bool
    Automatically set the width and height to half of the measured
    width and height.
    This only works for embedded images because it reads the width/height
    from image data.
    For non-embedded images, you can just set the desired display width
    and height directly.
unconfined: bool
    Set unconfined=True to disable max-width confinement of the image.
metadata: dict
    Specify extra metadata to attach to the image.

Examples
--------
# embedded image data, works in qtconsole and notebook
# when passed positionally, the first arg can be any of raw image data,
# a URL, or a filename from which to load image data.
# The result is always embedding image data for inline images.
Image('http://www.google.fr/images/srpr/logo3w.png')
Image('/path/to/image.jpg')
Image(b'RAW_PNG_DATA...')

# Specifying Image(url=...) does not embed the image data,
# it only generates `<img>` tag with a link to the source.
# This will not work in the qtconsole or offline.
Image(url='http://www.google.fr/images/srpr/logo3w.png')
File:           c:\users\hsingluliu\anaconda3\lib\site-packages\ipython\core\display.py
Type:           type
Subclasses:     
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/HsinglukLiu/article/details/107824705

智能推荐

Ubuntu下配置单节点伪分布式hadoop_ubuntu中伪分布式结果只有dfsadmin-程序员宅基地

文章浏览阅读798次。单节点伪分布式Hadoop配置首先申明,这里的配置方法也是我在网上找来的,并不完全时我个人经验的总结,这也是我看到的最简单和直接的配置方式,我虽然按照上面的配置闭关没有得到我想要的结果,下面的主要内容时我再用上面的方法进行配置的时候遇到的问题的解决方法,每个忍估计会遇到不同的问题,所以我贴出来很多我觉得能巩固解决问题的方法,与君共享! (声明:文档里面需要用户输入的均已斜体表示_ubuntu中伪分布式结果只有dfsadmin

CKeditor使用之添加自定义插件_ckeditor.dialog.add-程序员宅基地

文章浏览阅读9.3k次。首先就是在CKeditor的plugins目录下新建一个目录qchoice: qchoice目录下的结构如下:然后, images中如下: dialogs中如下:我们先来看plugins.js文件的内容:(function() { CKEDITOR.plugins.add("qchoice", { requires: ["dialog"..._ckeditor.dialog.add

Codejock Xtreme Toolkit Pro v12.0.0 Full Release-程序员宅基地

文章浏览阅读120次。地震了,发个东东纪念下载地址:http://www.fixdown.com/goload10.asp?id=9337&amp;gdcnc-downs3=42f42b7653ce2e6a_codejock.toolkitpro 12

using scp to copy file between linux server-程序员宅基地

文章浏览阅读122次。在linux系统中使用ssh非常的频繁,总是要在不同的机器之间传输文件。由于是在命令行下远程操作,使得传输文件不是很方便。但是scp将这一问题解决了。下面来看看把。 scp 命令是 SSH 中最方便有用的命令了,试想,在两台服务器之间直接传送文件,仅仅用 scp 一个命令就完全解决了。 你可以在一台服务器上 以 root 身份运行 scp servername:/home/...

C++经典算法题-打印菱形_用c++打印出菱形 * *** ***** ******* ***** *** *图案-程序员宅基地

文章浏览阅读796次。1. 题目题目:打印出如下图案(菱形)****************************2. 分析程序分析:先把图形分成两部分来看待,前四行一个规律,后三行一个规律,利用双重for循环,第一层控制行,第二层控制列。3. 代码示例 main() { int i,j,k; for(i=0;i<=3;i++) ..._用c++打印出菱形 * *** ***** ******* ***** *** *图案

React + TypeScript 实现泛型组件_react 函数组件泛型-程序员宅基地

文章浏览阅读3.4k次。泛型类型TypeScript 中,类型(interface, type)是可以声明成泛型的,这很常见。interface Props<T> { content: T;}这表明Props接口定义了这么一种类型:它是包含一个content字段的对象 该content字段的类型由使用时的泛型T决定type StringProps = Props&..._react 函数组件泛型

随便推点

金蝶KIS商贸版—(业务结账)期末结账操作介绍-程序员宅基地

文章浏览阅读6.2k次。业务结账业务系统中当一个业务期间已经结束,需要通过〖功能〗→〖业务期末结账〗来截止当期核算单据的处理,计算本期的库存商品成本余额,并转入下一期,同时系统当前期间下置。期末结账前,会对本期的核算单据进行检查,需要确保当前期间所有业务单据都已经审核。通过业务期末结账功能中的【查看】可以查找到当期所有未审核单据;专家温馨提示:1、业务期末结账构成:期末结账、反结账以及查看本期未审核单据。...

STM32程序异常——中断处理要谨慎-程序员宅基地

文章浏览阅读1.7k次。问题背景最近有一个新项目(车载项目),板子上除了原来的ARM + STM32F030K6Tx又多了一个8bit的mcu的单片机,这可真是嵌入式全家福了。系统的主要核心工作是由arm来完成,但是在开机早期及休眠、唤醒等过程是由stm32来控制完成的。开机过程中的ACC打火检测、高低压检测,同时也是为了保证休眠的时候整块板子的的低功耗(休眠时只有rtc有电及stm32处于深度休眠,其他全部..._stm32f030找不到adc中断

linux磁盘扩容、挂载[fdisk、parted]_linux fdisk 扩容-程序员宅基地

文章浏览阅读4.7k次。【代码】linux磁盘扩容、挂载[fdisk、parted]_linux fdisk 扩容

部署React新方式_react部署-程序员宅基地

文章浏览阅读1.5k次。# 为什么要使用ReactReact起源于Facebook内部项目,于2013年开源,由于出众的设计思想,以及更加专注于MVC当中的视图层, 使得创建交互式 UI 变得轻而易举。同时React还可以为你应用的每一个组件设计简洁的视图,当数据改变时 React 能有效地更新并正确地渲染组件。在写React时,就是在写每一个组件,最后将一个界面中的若干组件组合包装成完整页面,这样就实现了无论你现在正在使用什么技术栈,你都可以随时引入 React 来开发新特性,而不需要重写现有代码。跟随本教程,提升We_react部署

UVA 10065 Useless Tile Packers(凸包面积)_uva '10065-程序员宅基地

文章浏览阅读942次。UVA 10065 Useless Tile Packers(凸包面积)http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1006题意: 按时针顺序给你一个n个顶点的多边形(可能为凹多边形)的每个点,然后你要求出多少形的面积s1,以及多_uva '10065

程序员吐槽:公司开源节流要求降薪,网友:一石三鸟啊!_公司说开源节流 不涨工资-程序员宅基地

文章浏览阅读377次。一公司领导通知员工公司准备对全体员工做出降薪30%的决定,对此该公司员工表示不同意,一名程序员发帖怒怼:为了不让领导做如此艰难的决定,所以本人表示拒绝。2018年受金融大环境的影响,众多企业不可避免的进入了行业低迷期,这一年对我们来说,也是无比艰难,困难重重。为了尽快走出困境,公司只能开源节流,降低各项成本与开支。结合公司现状,也考虑到总体行业不景气,再就业困难等实际情况,公司领导做出了非常艰..._公司说开源节流 不涨工资