After installing Anaconda3 & PyCharm in new PC, I tried to test the same code as uploaded here
And I got a window like this.
But usually I use the plot window like this format (from google image search)
I think the first view is useful for checking all of the plots, but I'm already used to the second version, separated plot figure from PyCharm console, and I can use the control panel.
So I want to use PyCharm as in the second picture. How can I change my PyCharm settings to use the second version plot figure (extra window)?
That's because PyCharm is opening it in Sciview. Go to Settings => search for Python Scientific. Uncheck the (only) box Show plots in toolwindows. Restart PyCharm. It should work like a charm ;)
Related to my answer here.
According to this, you can manually change the backend to fix the issue:
matplotlib.use('Qt5Agg')
Credit to #ImportanceOfBeingErnest for digging up the thread.
You need first to check if you have Pycharm Community or Pycharm Professional.
You can plot in different windows just in case you have a professional version.
You can use seeting -> scientific python ( link : https://www.jetbrains.com/help/pycharm/matplotlib-support.html ).
Or, use matplotlib backends: Qt5Agg, Qt4Agg and TkAgg.
(https://intellij-support.jetbrains.com/hc/en-us/community/posts/360004382380-Matplotlib-doesn-t-show-plots-in-new-window )
However, I can suggest you to download your plot in a file and close the window. So, you can have your plots in different windows.
Check out this code:
file = '___your path___'
... make your code for visualisation
plt.show()
plt.savefig(file+'\\fig.png')
plt.close('all')
I was having the same problem, and not resolving it by only switching off scientific mode. Just press Cmd + Shift + A or Ctrl + Shift + A and search python scientific, then click on it and deselect show plots in tool window, you should be all set now.
Related
I am using PyCharm on my MacBook to code and now I wanted to make a simple plot. When I run the file via the usual 'Run' command (do not know what it is called), it nicely shows my plots, but when I run the file in the Python console (which I find more convenient because you can access your variables) it does not show anything. On the other hand, when I just type it in the Python console afterwards, it does work.
I have read some things about backends and other 'solutions' as I am apparently not the only one with this issue. Mine says macosx and gives the command: "Backend MacOSX is interactive backend. Turning interactive mode on." after running the file in the Python console. I tried changing the backend:
import matplotlib
# matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
but that does not work (no plot pops up). And yes, I use plt.show() after my plotting section :)
I also tried with 'QtAgg' but then I get: "ImportError: Failed to import any qt binding"
Now I am completely new to this backends stuff (I think it has to do with this), so I could really use some clear directions on how I can solve this issue.
Thanks in advance!
I am not sure we can solve this bug with some adjustment. I think you need to fresh start. I suggest you to start a new clean venv and install a new matplotlib there.
I am having a bit of trouble getting my plotly imports to work. I am a new Python programmer.
I followed the following instructions to a 'T':
https://plot.ly/python/getting-started/
When I copied the demo code into pycharm, I got errors on the imports. So I found a guy who had the same question as me here:
Import error : No module named plotly.plotly
Following prompts in the comments, I used "pip show plotly" in my command line, and copied and pasted the path, and reformatted the import like so (again as prompted by comments and the accepted answer:
import sys
sys.path.insert(0, 'c:\users\wesle\appdata\local\programs\python\python36-32\lib\site-packages')
import plotly.plotly as py
Still getting the same red squigglies...
Is plotly the right library to be using for a beginner? I will be using it to plot the results of numerical methods like calculating function values using taylor series and linear algebra stuff. I don't need super fancy, just whatever is easiest to code. By the way, really digging Python coming from Java.
So, I'm not a command line expert and decided to look within my IDE for a tool to set up plotly, as I was not having success with the "pip" stuff. I am using PyCharm, and the following simple steps took care of my problems in less than 30 seconds.
Settings
Click Project: "MyProjectHere" in left hand nav menu
Select Project Interpreter from the above drop down
Find the green 'plus' sign near the upper right edge of the window
that comes up.
Type Plotly in the search bar
Click install.
Maybe one day I won't be a dumb monkey who doesn't know how to use a command line like all the cool kids, but for now this worked for me.
If you are using Anaconda Python for notebook, you have to manually install plotly in anaconda:
Open Anaconda navigator
Go to Environments
Change installed to not installed
Search packages field and type plotly as uninstalled
Select it and click apply
After it gets installed you'll be able to import the package in notebook.
I'm using:
Python 2.7.3
matplotlib 1.4.1
Spyder IDE 2.3.8
My code has to produce a chart (combination of bar and scatter) . First run on the code succeeds in that, however all following executions (both run or debug) produce just an empty chart with correct grid, label, and legend, but no bars not scatter plot. I have to close Python console and open a new one to get the correct plot, and then the story repeats. In debugger I can see that all the data for the chart is fine.
I also tried Wing IDE (ver 5.1.10-1), and the very same code works fine all the time.
I found some suggestions about setting console preferences in Spyder (ie set GUI backend to Qt4Agg, agg, TkAgg, MAcOSX, Inline and such - none of those had any effect)
I would appreciate any help with this, as I'd prefer to use Spyder.
Many thanks
P.S. I used an earlier version of matplotlib without any issues, but recently I had to update it to ver 1.4.1 to use some libraries in an unrelated software project.
I've been using Visual Studio Community for a few months now, but the sluggishness and project-based interface is not to my liking and having seen that Visual Studio Code has a python extension, I decided to try Code again.
There are two problems with Code, that if possible to solve I'd promote it to my main editor.
First is intellisense. I have downloaded the python extension for Code, which promises intellisense. However, outside of the core python packages (like "math") intellisense is not working. I've tried to set up the extra environment variable as described in the link, but that didn't work either.
After this I re-crated an anaconda environment, just in case. Each anaconda environment basically operates as a separate python install and has the modules like "scipy" etc under Lib/site-packages to properly be able to reference them.
As you might guess, intellisense for VS Code still isn't working. Maybe there's a way to refresh its database like for VS Community but I couldn't find it.
My second issue is lack of auto-indentation for python, which wasn't the case when I first installed Code some 6 months ago. The issue was present 2-3 months ago, I hoped it was fixed by now but apparently not. There's nothing new written about it on the Internets either.
How do I get VS Code to work well for me with python?
I have installed python 3.6.5 and Django 2.0.4 on windows 10 OS.
In vs code open command palette (Ctrl+Shift+p).
There select Python:Select Interpreter
Close your vs code and then try. If it still does not work. Try again by changing to:-
Python:Build Workspace symbols and re-open the vs code. That's all i did and got intelligence enabled.
Old question that worth another working answer:
In settings.json, set the value of python.jediEnabled to false (see some more details here).
P.S. You can also try and move back to Jedi (just remove python.jediEnabled or set it to true), and in my case, Intellisense keeps working, though much slower.
This is how I got Python intellisense to start working in VS Code:
open up the Terminal (View menu => Terminal)
type conda init powershell
restart VS Code
After that, Python intellisense started working correctly for me.
On your VS code use the command ctr + shift + P then search for Python: Select Lint and choose your preferred linting tool. This worked for me.
Bro, instead of
import matplotlib.pyplot as plt
Try:
from matplotlib import pyplot as plt
I've tried it in VSCode and it works for the second statement but not the first statement.
This is how I got it to work:
Open command palette (Ctrl + Shift + P).
Type "Python: Build Workspace Symbols" and hit Enter.
Done.
I am using Anaconda with Python 2.7 in the Spyder environment. When plotting a pyplot, the window hides behind all my other open windows instead of appear in front. How would I make the figure appear in front of all other open windows?
The matplotlib backend is: Qt4Agg
(Spyder dev here) The only backend that have this functionality is the TkAgg one. The code posted by #valentin in his/her answer should work when using that backend.
All other backends miss this possibility. This has been a known limitation of Matplotlib for quite some time, as can be seen in this Github issue.
You can try something like:
fig = plt.figure()
plt.show()
fig.canvas.manager.window.activateWindow()
fig.canvas.manager.window.raise_()
But the desired behaviour is backend dependent.
On tkinter:
fm = plt.get_current_fig_manager()
#bring to front
fm.window.attributes('-topmost', 1)
#allow other windows to cover
fm.window.attributes('-topmost', 0)