문제 설명
iPython 셸에서 인라인으로 플롯할 수 없음(터미널 및 VScode 터미널 창) (Can't plot inline in iPython shell (Terminal and VScode terminal window))
내 iPython 셸이 인라인 및 외부에서 플롯하지 않는 이유를 이해하도록 도와줄 사람이 있습니까? 대신 창? Jupyter 노트북에 대해 말하는 것이 아닙니다. 나는 그 일을 했다. 도움을 주시면 감사하겠습니다. 감사합니다 ...
물론 제 문제를 해결하기 위해 여러 소스를 시도했습니다.
- Stackoverflow: ‑> 작동하지 않음
- matplotlib.org ‑> 동일
- ipython 문서 ‑> 동일
- Google에서 제안한 다른 몇 개 ‑> 동일
(py310_env) Murat ~ % ipython
Python 3.10.0 (default, Nov 10 2021, 11:24:47) [Clang 12.0.0 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.1.1 ‑‑ An enhanced Interactive Python. Type '?' for help.
The following code will plot, but **not inline**:
In [1]: import matplotlib.pyplot as plt
In [2]: import numpy
In [3]: %matplotlib
Using matplotlib backend: MacOSX
In [4]: plt.plot([0,1,4,9,16])
Out[4]: [<matplotlib.lines.Line2D at 0x7f7821f3cfa0>]
이 문장도 시도했습니다.
`%matplotlib inline´
이 문장을 시도하면, 그런 다음 플롯의 외부 표시조차 하지 않는 다음과 같은 결과를 얻었습니다.
In [6]: plt.plot([0,1,4,9,16])
Out[6]: [<matplotlib.lines.Line2D at 0x7f7823002020>]
<Figure size 432x288 with 1 Axes>
내 백엔드가 그렇게 변경되어야 한다고 생각했습니다. 해봤는데 안바꿔요.
In [8]: %matplotlib qt
Warning: Cannot change to a different GUI toolkit: qt. Using osx instead.
In [9]: matplotlib tk
Warning: Cannot change to a different GUI toolkit: tk. Using osx instead.
참조 솔루션
방법 1:
Unless someone suggests a better solution, here is my cure.
Initially I had been trying to invoke ipython in the CLI using the command %ipython
.
My conclusion is now, you need to use Jupyter Qt‑console
(available in the Anaconda distro. (Spyder, Jupyter and PyQT are preinstalled)
%jupyter qtconsole
: QT will open up Terminal style console for Python and it does the inline plot magic.