-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture 3: matplotlib on Sagemathcloud #1
Comments
I strongly encourage you to use np.linspace, not np.arange. That said, I don't see a similar error. Can you post the specific .py or .ipynb file that is giving you this error? |
Thanks! As mentioned above, using this code as is on jupyterNotebook works fine without problems. The problem happens only when used inside ipython, run from a terminal window. Or if the code is inside a .py script, run from a terminal window too. I believe it has to do with the way my account is configured. It would be nice if that's not the case. The python script is attached as a .txt. |
I verified that the previously attached python script runs locally on my computer without errors, but complains on sagemathcloud about TclTk. |
I can't reproduce the TclTk error; if you are curious about that, please send the exact series of commands you used on SMC. However, if you do not have a "display" for the plot, I don't think that you can use the plt.plot command anyway. I'm not sure why you are trying to avoid Jupyter when you run a plotting script on SageMathCloud, but this may help you: https://stackoverflow.com/questions/15713279/calling-pylab-savefig-without-display-in-ipython |
The exact sequence matches exactly what I sent in the python script attached. Did you manage to run the script from the terminal and get the display to work? Yes my issue is not being able to get matplotlib.pytplot.plot to run from inside a python script on sagemathcloud. I am not trying to avoid jupyterNotebook, I am just assuming that a syntactically correct python script should run. Thanks for the stackoverflow link, I'll take a look. |
I did try from the terminal, in 4 different ways, but I did not get a TclTk error, which is why I asked for the commands you ran from the terminal. The Python script that you gave is not giving me that problem, so I need to know how you ran it. However, I did get a different error due to the fact that SageMathCloud has no display for a bare Python command. If you are not using a Jupyter notebook, the process does not have any display to plot on, so you get an error. Technically speaking, the Python script is working perfectly, but the environment does not provide it with any way to display the output, so it has to produce an error. matplotlib.pyplot.plot should not work without an X display (or some equivalent). The link I provided should explain a way around it, namely two methods of creating a plot that can be saved without trying to display the output to a screen. |
Okay, now I understand. The TclTk error showed up when I ran the commands in the script inside ipython, but ran this instance of ipython from the terminal, and not in JupyterNotebook. Should I conclude that, in general, to be safe regarding running our python scripts, we should run the tests from jupyterNotebook but not the terminal? |
I would recommend that you keep any plotting commands specifically in a Jupyter notebook, or that you turn off interactive plotting in your scripts and simply save a file instead. However, it's fine to run the tests from the terminal as long as they don't produce plots. Personally, I would separate things out like so:
|
I tried to run the following code on jupyterNotebook and it properly plots the output.
However, when I try to run it from inside ipython in a terminal window or inside a python module, I get the following TclTk error. I do not understand why this is happening.
The text was updated successfully, but these errors were encountered: