I am trying to run python in XCode. The following simple plotting routine,
import matplotlib.pyplot as pyplot
pyplot.plot((0,1),(1,2))
pyplot.show()
returns no errors. XCode seems pretty happy with what it accomplishes when I hit the run button. But I get no plot window whatsoever, as far as I can tell. Is it hiding somewhere or what? How do I get to see it?
xcode will allow you to see plots if you move your code into an interactive notebook.
create a new file with the .ipynb file extension
copy your code into that file
You should be able not only to see the plots but also any other output your code is trying to send to the UI.
Related
I don't really like working in Jupyter enviroment and prefer raw Python. Is it posible to plot graphs directly in VSC via .py file? If I put my code to Jupyter cell in Jupyter file (.ipynp) the visualization works fine directly in VSC.
I use plotly or matplotlib, but i am willing to learn other packages if needed.
Is there for example some extencion to VSC that I could use? Or is it posible to plot to jpg/html file that I could open with file explorer?
Edit:
I made a newbie mistake. I didn't use command plt.show() to plot the matplotlib graph.
But GNU plotter suggested by Charudatta is also great solution
try GNU plotter works great for plotting
I don't think you can, you can't display images in a terminal
I found a way to implement interactive slider using Bokeh without relying on Bokeh server, since Bokeh server doesn't work in VS code.
But this new way doesn't work in vs code either, though it still works in web browser.
Is it possible to run it in vs code?
The jupyter mentioned in your link is used, so please install the jupyter extension and create the .ipynb file.
I used the basic interactor demo in the link.
After all execution, I can get the content shown in the figure:
Of course, when you adjust the scroll bar below, you need to rerun the penultimate cell:
I am working in python and using Anaconda with Spyder and I need to plot a scatter plot in a part of the code I am working on. The plot is just fine but is drawn in the console itself and the size is quite small for my needs.
My question is, how can I plot it in another window outside the ipython console? I already tried changing some of the setting like changing Graphics setting in ipython from inline to QT to tkinter. Nothing seems to work.
Any helpful suggestions?
you can just save %matplotlib qt in a .py file and you can start ipython using:
ipython -i myfile.py
I'm writing plot functions in python scripts and using ipython to show them. I want to show the figures inside the page ,so that I used
%matplotlib inline
After that I can show the figures inside.
Is there a way to put this line inside the plot.py script so in ipython I just import the .py without specifying the %matplot code?
Thanks.
You should only have to run %matplotlib inline once per IPython session. All it does it tell matplotlib to plot graphs inline, as opposed to in a separate window.
Running it more than once (say once per script) seems pointless as it won't actually do anything. You could just run it at the top of your session and then not worry about it, your plots will still plot and you can still have plotting functions inside the Python files.
That aside, adding it inside a script is just not possible. It just returns a SyntaxError because you effectively run it as a Python script, not in the IPython terminal where it's set up to handle the magic methods.
I'm using IPython notebooks to share code and (hopefully) graphics with m collaborators. sadly, I cannot get matplotlib to plot inside the notebook, it always gives me a pop-up window, which I obviously cannot include in notebook pastes or similar.
Here's two minimal examples of how I go about plotting things.
Either with invoking plt.show() , or without it.
this either gives me an external pop-up, or plots nothing.
You need to be using the matplotlib inline backend.
%matplotlib inline