Closed minertom closed 3 years ago
Hi Tom,
I am assuming you figured this out by now since you already closed the issue :-) But, answering your question, the key is in Jupyter notebook's "magic" command: %matplotlib inline, which captures the figures generated by matplotlib and displays them inside the notebook.
Anyway, if you want to learn a bit more about matplotlib's display options, this material from Jake VanderPlas is really good: https://jakevdp.github.io/PythonDataScienceHandbook/04.00-introduction-to-matplotlib.html
Best, Daniel
Hi and I do appreciate your help.
I closed the issue because I found that matplotlib can be used in interactive mode, non interactive mode and with "backends", of which, jupyter, is one of them. There is a "block" involved, which just says that if one is returning from a python function, like you do in figure1, figure2...etc, there is no block and plt.show() is not required.
From the matlab documentation: https://www.google.com/search?channel=fs&client=ubuntu&q=matplotlib+when+is+plt.show%28%29+needed
Also, I checked in chapter0, you never did use "%matplotlib inline " but at least now, I am closer to understanding what it does.
Thank You Tom
On Mon, Nov 23, 2020 at 1:00 PM Daniel Voigt Godoy notifications@github.com wrote:
Hi Tom,
I am assuming you figured this out by now since you already closed the issue :-) But, answering your question, the key is in Jupyter notebook's "magic" command: %matplotlib inline, which captures the figures generated by matplotlib and displays them inside the notebook.
Anyway, if you want to learn a bit more about matplotlib's display options, this material from Jake VanderPlas is really good:
https://jakevdp.github.io/PythonDataScienceHandbook/04.00-introduction-to-matplotlib.html
Best, Daniel
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dvgodoy/PyTorchStepByStep/issues/9#issuecomment-732423150, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADHGGHFESQARO6DLCZYFIODSRLEPTANCNFSM4T7AJ46Q .
Hi, and i realize that this may be trivial.
In your "figures" you are using python functions that are defined in the "plots" directory.
In the jupyter notebook you use
figure1(x_train, y_train, x_val, y_val
This calls the function `def figure1(x_train, y_train, x_val, y_val): fig, ax = plt.subplots(1, 2, figsize=(12, 6))
` I notice that there is no plt.show() statement that is needed, either in the function or in the jupyter notebook.
However, if I am at the command line (not using the jupyter notebook) and I enter the python code line by line and make the "figure" call, I don't get a plot unless I use "plt.show()" as the next line after the figure call.
Can you tell me why plt.show() is not necessary for the jupyter notebook but it is necessary when calling the function from the command line?
Thank You Tom