SciPy初学者(day three)

今天,我们来把教程里剩下的东西了解完
首先,我们来了解一下Subplots
我们可以使用Subplots中的一些函数来绘制一些东西,以下是例子

import numpy as np
import matplotlib.pyplot as plt

x =np.arange(0, 3 * np.pi , 0.1)
y_sin = np.sin(x)
y_cos = np.cos(x)

plt.subplot(2,1,1)
plt.plot(x, y_sin)
plt.title('Sine')

plt.subplot(2, 1, 2)
plt.plot(x, y_cos)
plt.title('Cosine')

plt.show()

结果如下图所示
在这里插入图片描述
接下了我们来看最后一点Images
你可以使用imshow的方法来显示图片,下面是个例子

import numpy as np
from scipy.misc import imread, imresize
import matplotlib.pyplot as plt

img = imread('C:/Users/Administrator/Pictures/1.jpg')
img_tinted = img * [1, 0.95, 0.9]

# Show the original image
plt.subplot(1, 2, 1)
plt.imshow(img)

# Show the tinted image
plt.subplot(1, 2, 2)

# A slight gotcha with imshow is that it might give strange results
# if presented with data that is not uint8. To work around this, we
# explicitly cast the image to uint8 before displaying it.
plt.imshow(np.uint8(img_tinted))
plt.show()

显示结果如下图所示(随便找了个图片)
在这里插入图片描述
还是会有以前提到的那个问题,就是scipy的版本问题,
现在版本是1.2.0, imread()改成了imageio.imread()
虽然报错了,但是结果还是显示出来了,奇怪

心得:通过这2个星期的了解,也算对python以及其的库有了一些的认识,能正常使用,但还需深入了解。
这个Python的初级了解就到这里结束了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值