显示两张图片的代码:

import numpy as np
from scipy.misc import imread, imsave, imresize
import matplotlib.pyplot as plt img = imread('cat.jpg')
print(img.dtype, img.shape) # uint8 (500, 500, 3) img_tinted = img * [1, 0.1, 0.5] # RGB
img_tinted = imresize(img_tinted, (300, 600))
imsave('cat_tinted.jpg', img_tinted) plt.subplot(1, 2, 1)
plt.imshow(img) plt.subplot(1, 2, 2)
plt.imshow(img_tinted) plt.show()

显示结果:


显示四张图片的代码:

x = np.arange(0, 2 * np.pi, 0.1)
y_sin = np.sin(x)
y_cos = np.cos(x) plt.subplot(2, 2, 1)
plt.plot(x, y_sin)
plt.plot(x, y_cos)
plt.xlabel('x axis label')
plt.ylabel('y axis label')
plt.title('Sine and Cosine')
plt.legend(['Sine', 'Cosine']) plt.subplot(2, 2, 2)
plt.plot(x, y_sin)
plt.title('Sine')
plt.legend(['This is Sine']) # img = imread('cat.jpg')
plt.subplot(2, 2, 3)
plt.imshow(img) plt.subplot(2, 2, 4)
plt.imshow(np.uint8(img_tinted)) plt.show()

显示结果:


计算任意两点间的欧氏距离

from scipy.spatial.distance import pdist, squareform
x= np.array([[0, 1], [1, 0], [2, 0]])
d= squareform(pdist(x, 'euclidean'))
print(d)

[[0. 1.41421356 2.23606798]

[1.41421356 0. 1. ]

[2.23606798 1. 0. ]]

matplotlib 显示两张图片,折线图 和 scipy的更多相关文章

  1. 3-Highcharts曲线图之显示点值折线图

    直接上代码  根据代码注释讲解 <!DOCTYPE> <html lang='en'> <head> <title>3-Highcharts曲线图之显示 ...

  2. Matplotlib基本图形之折线图

    Matplotlib基本图形之折线图折线图特点 折线图是用折线将各数据连起来组成的图形常用来观察数据随时间变化的趋势例如:股票价格,温度变化,等等 示例代码: import os import tim ...

  3. 【学习总结】GirlsInAI ML-diary day-21-初识 Numpy, Matplotlib, Seanborn [柱状图、折线图、箱图]

    [学习总结]GirlsInAI ML-diary 总 原博github链接-day21 初识 Numpy, Matplotlib, Seanborn [柱状图.折线图.箱图] 一.Titanic练习赛 ...

  4. python中matplotlib绘图封装类之折线图、条状图、圆饼图

    DrawHelper.py封装类源码: import matplotlib import matplotlib.pyplot as plt import numpy as np class DrawH ...

  5. echarts在数据改变后,折线图并没有全部刷新

    在做一个BI项目的时候,图表需要区分国内和国外显示.当前用户所属企业具备国内外权限的时候,展示两条图表,当查看其他企业需要根据选中的企业所具备的权限改变图表.即刚开始显示两条折线图,更改选择条件并重新 ...

  6. react-echarts之折线图的显示

    react中想要实现折线图和饼图的功能,需要引入react-echarts包,然后再实现折线图的功能.我这里引用的版本是:0.1.1.其他的写法参echarts官网即可.下面详细讲解的是我在react ...

  7. ECharts折线图多个折线每次只显示一条

    echart 两条折线图如何默认只显示一条,另一条隐藏呢 只需要在legend后加上, selectedMode: 'single', selectedMode [ default: true ] 图 ...

  8. Python_散点图与折线图绘制

    在数据分析的过程中,经常需要将数据可视化,目前常使用的:散点图  折线图 需要import的外部包  一个是绘图 一个是字体导入 import matplotlib.pyplot as plt fro ...

  9. IOS使用Core-Plot画折线图

    关于Core-Plot的配置.大家能够參考我的上一篇博客:http://1.wildcat.sinaapp.com/?p=99 版权全部.转载请注明原文转自:http://blog.csdn.net/ ...

随机推荐

  1. Android学习心得(13) --- Android代码混淆(1)

    我在博客上发表一些我的Android学习心得,希望对大家能有帮助. 这一篇我们讲述一下最新的ADT环境下怎样进行Android混淆 在新版本号的ADT创建项目时.混码的文件不再是proguard.cf ...

  2. QQ好友列表数据模型封装

    QQ好友中的信息较多.假设我们单独从plist 中直接取出数据 是能够解决这个问题 可是相当复杂.以为列表中分组 .每组中还有不同信息 大致模型是 数组套数组  数组套字典 所以我们要封装数据模型 / ...

  3. AlterDialog 经常使用的样式

    使用AlerDialog 创建对话框 : AlertDialog.Builder builder = new AlertDialog.Builder(this); 1.设置简单的对话框 builder ...

  4. C++编程-&gt;pair(对组)

    pair 是 一种模版类型.每一个pair 能够存储两个值.这两种值无限制,能够是tuple.vector ,string,struct等等. 首先来看一下pair的函数 初始化.复制等相关操作例如以 ...

  5. C语言学习笔记:15_c语言中的进制操作.c

    /* * 15_c语言中的进制操作.c * * Created on: 2015年7月5日 * Author: zhong */ #include <stdio.h> #include & ...

  6. PbootCMS V1.1.4 正式发布

    PbootCMS V1.1.4 正式发布 PbootCMS V1.1.4 build 2018-06-251.修复自定义表单表名重复仍然添加成功问题:2.修复分享到微信导致页面错误的问题:3.修复静态 ...

  7. java根据内容生成二维码图片

    package util; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; ...

  8. UIViewController生命周期控制

    UIViewController生命周期控制 UIViewController介绍 官方的介绍例如以下 The UIViewController class provides the fundamen ...

  9. c22---枚举

    // // main.c // 枚举基本概念 #include <stdio.h> int main(int argc, const char * argv[]) { // int sex ...

  10. Node.js:工具模块

    ylbtech-Node.js:工具模块 1.返回顶部 1. Node.js 工具模块 在 Node.js 模块库中有很多好用的模块.接下来我们为大家介绍几种常用模块的使用: 序号 模块名 & ...