在Pycharm中关闭matplotlib图

时间:2019-04-02 13:24:24

标签: python matplotlib pycharm

我想使用PyCharm使用matplotlib绘制图形,显示图形几秒钟,然后关闭图形窗口。

简单搜索后,我得到了以下代码。当在IDLE /终端中运行Python时,此方法有效。

{
  "name": "so-portal-rwd",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.11",
    "@angular/cdk": "^5.2.5",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.5.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/material": "^5.2.5",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@angular/service-worker": "^6.0.5",
    "@ng-idle/core": "^2.0.0-beta.15",
    "@ng-idle/keepalive": "^2.0.0-beta.15",
    "adal-angular5": "^1.0.36",
    "angular-user-idle": "^1.1.0",
    "angular-webstorage-service": "^1.0.2",
    "angular2-draggable": "^1.4.2",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.4.1",
    "crypto-js": "^3.1.9-1",
    "hammerjs": "^2.0.8",
    "marked": "^0.4.0",
    "mat-video": "^2.5.1",
    "ng2-dnd": "^5.0.2",
    "ng2-file-upload": "^1.3.0",
    "ng2-pdf-viewer": "^5.1.0",
    "ngx-carousel": "^1.3.5",
    "ngx-webstorage": "^3.0.2",
    "ngx-webstorage-service": "^4.0.1",
    "npm": "^6.5.0",
    "rxjs": "^5.5.6",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular-devkit/core": "^0.5.13",
    "@angular/cli": "~1.7.3",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/marked": "^0.4.0",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.0",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }
}

但是plt.close('all')似乎没有关闭PyCharm产生的任何绘图窗口。

如何以编程方式关闭PyCharm生成的绘图窗口?有人问过这个问题(Close a figure - PyCharm,但是接受的解决方案不起作用。

1 个答案:

答案 0 :(得分:1)

我猜您使用的是SciView。因此,您需要更改pycharm中的设置。

Settings | Tools | Python Scientific | Show Plots in Toolwindow - box has to be unticked to back to the usual matplotlib figure window 

在此之后,再试一次。