当前位置:网站首页>pychrm社区版调用matplotlib.pyplot.imshow()函数图像不弹出的解决方法
pychrm社区版调用matplotlib.pyplot.imshow()函数图像不弹出的解决方法
2022-07-06 11:02:00 【--吉择--】
前言
学习吴恩达老师的deeplearningai课程,完成第二周编程作业二,想自己在pycharm中重新写一遍代码,发现加载完数据集后图像不显示。
环境
win10
anaconda3
python3.8
pychrm-community-2022.1.3
解决方法
方法一:
导入pylab库(pylab是matplotlib中的一个模块,直接导入即可。)
在plt.imshow(train_set_x_orig[index])后加一句pylab.show()
import numpy as np
from matplotlib import pyplot as plt
import h5py
import scipy
from PIL import Image
from scipy import ndimage
import scipy.misc
import pylab
def load_dataset():
train_dataset = h5py.File('datasets/train_catvnoncat.h5', "r")
train_set_x_orig = np.array(train_dataset["train_set_x"][:]) # your train set features
train_set_y_orig = np.array(train_dataset["train_set_y"][:]) # your train set labels
test_dataset = h5py.File('datasets/test_catvnoncat.h5', "r")
test_set_x_orig = np.array(test_dataset["test_set_x"][:]) # your test set features
test_set_y_orig = np.array(test_dataset["test_set_y"][:]) # your test set labels
classes = np.array(test_dataset["list_classes"][:]) # the list of classes
train_set_y_orig = train_set_y_orig.reshape((1, train_set_y_orig.shape[0]))
test_set_y_orig = test_set_y_orig.reshape((1, test_set_y_orig.shape[0]))
return train_set_x_orig, train_set_y_orig, test_set_x_orig, test_set_y_orig, classes
train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dataset()
index = 5
plt.imshow(train_set_x_orig[index])
pylab.show()
print("y = " + str(train_set_y[:, index]) + ", it's a '" + classes[np.squeeze(train_set_y[:, index])].decode(
"utf-8") + "' picture.")

方法二:
在plt.imshow(train_set_x_orig[index])后加一句plt.show()
PS
- 网上有中解决方法是pycharm–>File | Settings | Tools | Python Scientific | 取消勾选Show plots in tool window,但我的pycharm里根本没有Python Scientific这个选项
- pycharm使用plt不显示图片解决方案
这篇博客解释了为什么在jupyter中可以显示而pycharm中不可以显示。 - 感觉中科大的镜像源蛮好用
pip3 install -i https://pypi.mirrors.ustc.edu.cn/simple/ pylab
边栏推荐
- Nuc11 cheetah Canyon setting U disk startup
- 美庐生物IPO被终止:年营收3.85亿 陈林为实控人
- Penetration test information collection - App information
- 抽象类与抽象方法
- This article discusses the memory layout of objects in the JVM, as well as the principle and application of memory alignment and compression pointer
- MySQL查询请求的执行过程——底层原理
- Numerical analysis: least squares and ridge regression (pytoch Implementation)
- Human bone point detection: top-down (part of the theory)
- Some recruitment markets in Shanghai refuse to recruit patients with covid-19 positive
- Celery best practices
猜你喜欢

Nuc11 cheetah Canyon setting U disk startup

Execution process of MySQL query request - underlying principle

使用cpolar建立一个商业网站(1)

手写一个的在线聊天系统(原理篇1)

巨杉数据库首批入选金融信创解决方案!

ORACLE进阶(四)表连接讲解

Collection of penetration test information -- use with nmap and other tools

Self-supervised Heterogeneous Graph Neural Network with Co-contrastive Learning 论文阅读
![[depth first search] Ji suanke: find numbers](/img/e4/708a1e8252bcd2d0d621c66bf6bfed.jpg)
[depth first search] Ji suanke: find numbers

openmv4 学习笔记1----一键下载、图像处理背景知识、LAB亮度-对比度
随机推荐
关于npm install 报错问题 error 1
华为0基金会——图片整理
Hongke shares | plate by plate ar application in Beijing Winter Olympics
AvL树的实现
Stm32+esp8266+mqtt protocol connects onenet IOT platform
atcoder它A Mountaineer
Handwritten online chat system (principle part 1)
Online notes
【中山大学】考研初试复试资料分享
test about BinaryTree
Some recruitment markets in Shanghai refuse to recruit patients with covid-19 positive
十、进程管理
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人
使用map函数、split函数一行键入多个元素
Introduction to the use of SAP Fiori application index tool and SAP Fiori tools
MySQL查询请求的执行过程——底层原理
DOM简要
AcWing 3537. Tree lookup complete binary tree
安装及管理程序