在pycharm中使用 %matplotlib inline
語句會報錯
但是刪掉又會不顯示圖表,怎么辦呢?
解決:刪掉或者這行代碼,用 plt.show()
展示圖表。
附:
%matplotlib作用
- 是在使用jupyter notebook 或者 jupyter qtconsole的時候,才會經常用到%matplotlib,也就是說那一份代碼可能就是別人使用jupyter notebook 或者 jupyter qtconsole進行編輯的。
- 關於jupyter notebook是什么,可以參考這個鏈接:[Jupyter Notebook介紹、安裝及使用教程]
- 而%matplotlib具體作用是當你調用matplotlib.pyplot的繪圖函數plot()進行繪圖的時候,或者生成一個figure畫布的時候,可以直接在你的python console里面生成圖像。