Getting Visual Studio Code Figure in Anaconda Python - python

I was trying Visual Studio Code that comes with Anaconda
There was heaps of problems that I could not get a simple python code to run successfully there
but on the other hand there was some really nice features
beside the autocomplete feature that I liked
Using the standard plotting
import matplotlib.pyplot as plt
plt.scatter(df['Col1'], df['Col2'])
there was the Figure which gives you many options to do with the graph including zoom in, change access and many more.
is there something similar or any other way that can give me same Figure feature in VSCode?

Make sure you select an Anaconda environment and then if you use the Jupyter support you can get the plots shown in the interactive window.

Related

Import is working properly but Python Support in VSCode shows warning

I am now focusing on Data Visualization with Matplotlib, and the issue I mentioned really distracts me while practicing on Python.
There is no problem after running the code. I can get expected results. Although two files are in the same directory without any typos, Visual Studio lists the following warning all the time:
import "random_wall" could not be resolved
There was a link which opened github when I clicked the first time, but now the link is not there any more.
I upload two images to help you understand my problem visually. Thanks in advance.
Python code with its issue
see the directory of files
The issue is basically with your virtual environment that is set in visual studio code. Change the virtual env to the one where the package is installed and it will stop showing the import warning. You can change your virtaul env in the bottom left corner or by clicking ctrl+shift+P and search for interpreter which will show you a drop down of the available interpreter in the system.

My VS code interface for Jupyter notebook is very different from the new version

I recently started learning python for data analysis and decided to use VS code for its new Jupyter notebook feature. I installed the extension for python and jupyter notebook in VS code but for some reason my interface is very different from the one in the new update.
I understand this is a small issue but, It's really throwing me off. Can someone please let me know what I am doing wrong here?
Thank you
Seems you're using VS Code Insider, check if it's titled as Visual Studio Code- Insiders:
Download VS Code and you'll get the normal layout:

Is there a way to open graphs in a new window in VSCode?

I'm graphing some stuff with matplotlib and I need to be able to zoom in on the graph. But VSCode just renders it in its Python Interactive window that I can't do anything with. Is there a way to open graphs in a their own window that allows for scaling and things?
I'm a developer on this extension. We don't currently support popping out graphs. If you want to vote up the issue, we have an issue filed for this support here:
https://github.com/Microsoft/vscode-python/issues/4976
Until this support is added there is a bit of a work around. You can manually use the %matplotlib ipython magic to update to non-inline rendering. Then when you show plots they will be shown in a popup window. Like so:
I can't tell you exactly what command to use as it might vary based on what you have installed in your environment. But %matplotlib auto or %matplotlib qt would be good places to try starting with.

Matplotlib figure windows cannot be focused or switched to through cmd+tab

I'm using matplotlib 2.2.2. with ipython 3.6.5 (both from anaconda) for data analysis. Whenever I create a figure window with some boilerplate code like
import matplotlib.pyplot as plt
plt.ion()
plt.plot()
I get a nice figure window to which I can only switch focus by using with the mouse. These figure windows are not part of the list of macosx application switcher (accessible through cmd+tab shortcut). I've tried the osx and the qt5 backends, but I get the same results as described before.
Do you know any solution/workaround for this? It would be very practical to be able to switch focus between figure windows from the keyboard, as I often find myself browsing through the figure windows looking for the graph I'm interested in. Moreover, if matplotlib's figure windows were actual cocoa/macos windows, it would be extremely useful to those out there who use tiling window managers on osx.

Distributing an interactive matplotlib plot

I have a Python script that generates an interactive matplotlib plot with several sliders and radio buttons using the matplotlib.widgets submodule. I'd like to let others play with the resulting plot without having to install python, scipy, numpy, and matplotlib.
I first tried converting my python script to a stand-alone executable that I could distribute. This turned out to be a nightmare - every package I tried (pyinstaller, py2exe, cx_Freeze) failed for one reason or another. The main issue I had was with integrating various scipy and matplotlib libraries, and I'm now very pessimistic about successfully "freezing" my interactive plot.
My next idea was to see if I could get some interactivity through a web browser. Using an IPython notebook with the third-party package JSAnimation initially seemed very promising (http://nbviewer.ipython.org/github/jakevdp/JSAnimation/blob/master/animation_example.ipynb), but it seems that the package only supports the matplotlib "animate" function. This doesn't quite fit the bill for what I'd like to do, as I have multiple sliders which 1) doesn't seem to be supported by this package, and 2) even if supported, would likely result in too many static figures to pre-render effectively, since any such arrangement would require snapshots for every possible combination of the three variables.
Any ideas for how to get this interactive matplotlib plot to others without requiring them to install Python?

Categories