How can Pycharm (with matplotlib) show me my graphs in the same Py charm, next to my code?. Not in additional windows - python-3.x

i am using Matplotlib with Pycharm in a Mac osx. When I am making a graph, and I code plt.show() pycharm opens another window. And if there is 2 graphs, to see the 2nd one I have to close the first one. And I want to see both together.
There is a option to show the two graph in the same window, where my code is?
Thanks very much.

This link may help:
IPython magic commands
Using Jupyter notebooks you can achieve what you want by using %matplotlib inline. It seems from the link above that PyCharm may have some way to enable this same functionality.
See also: Inline plots in the scientific view

Related

VS Code input and variables don't show frequently in Interactive window

I have started using VS Code for work instead of Anaconda and there are some weird observations which I am not able to figure out.
If I try to execute some code in a cell in the interactive window, many-a-times, only output remains available and the input code automatically gets hidden. For eg. I type the following and execute:-
And this is what I see at the window:-
Similarly, there are some variables which I have already defined but they don't show up in the Jupyer:Variables tab. For eg. there is a variable _link_name_to_index which is not visible in the tab as shown below:-
However, when I execute the same in the window, I can see the values of the dictionary as expected:-
Maybe it is just a matter of some settings, but I still couldn't find out which one. Also, I know I have put a lot of images, because it is not a code doubt as such, rather more of a tool doubt. I have taken only one particular example here, but I face this issue often. I am using VS Code version 1.75.0 in Ubuntu 20.04, using Python 3.9.12 in a virtual environment, if it helps.
This is a bug in the latest Version of VSCode (1.75). It is tracked in this issue. For now, the only option seems to be downgrading to v1.74.x

matplotlib randomly shows no plot in figure window

I am using Python 3.8.16 on Ubuntu 18.04.6 LTS and work with matplotlib 3.6.2, but do not use Jupyter in this case. When I plot a graph with matplotlib, sometimes happens that I get the figure window, but without any content, except the window title "Figure 1". I cannot close the figure with "q", and usually cannot break the execution with ctrl C, however ctrl \ usually works. When I run the program again, usually everything is fine. I would say that the probability, that the plot will be shown properly is around 80-90%. I had the same behaviours with Python 3.7 and with previous versions of matplotlib - seems it is not version specific. The problem occures in diferent programs. The matplotlib.get_backend() command returns TkAgg, and the posts in discussion groups suggest it is ok in case of Ubuntu. I couldn't find any solutions on internet forums so would appreciate any hint.

Jupyter's tab auto-complete is not working for several libraries like- sklearn, numpy, seaborn, pandas and matplotlib etc

Whenever I am using jupyter in the default directory (used by jupyter after installing anaconda) tab auto complete works fine. After entering a dot if I press the tab the list of methods and attributes appears.
Now, if I launch Jupyter notebook from a different location (say D drive) using anaconda prompt (command line), jupyter notebook appears, but for several libraries like sklearn, numpy, seaborn, pandas and matplotlib tab auto-complete after a dot is not working. However, when I write:
from sklearn.
and then press tab then I can see the options, similarly for other libraries too (below is one such screenshot).
Surprisingly the same never happens when I write:
import numpy as np
import sklearn
import seaborn as sb
np. # nothing appears upon pressing Tab after a dot
sb. # nothing appears upon pressing Tab after a dot
sklearn. # nothing appears upon pressing Tab after a dot
I have read some solutions on the internet where they mention about some plugin/extensions to use, but I don't want them to be used, I kind of prefer what jupyter already offers.
Could someone please help me with this issue...?
P.s.: I'm not still sure with what all other libraries the issue still persists, I happen to frequently use these so far....

running a Program from vim that opens another window messes up the formating of my terminal

Im using vim inside a gnome-Terminal to edit a Python Program. Im also using a tiling Window manager calles awesome-wm.
Inside my Python program im plotting some data to a matplotlib graph (when executed that opens another window). When i want to test my Program i use the following comand to run the Program from inside of vim.
:!python3 %
when the Program runs it prints three messages to the shell and opens a matplotlib window to plot the data.
Sometimes i can only see the messed up linebreaks and have to scroll up to see the messages.
My question now is why is the formating inside the console messed up an how do i fix it?
My guess would be that the Terminal Window does not notice that it is beeing resized when the plot window is beeing opend, but i dont know how to refresh the terminal in that case.
using :!clear; python3 % does not help.
Thanks in advance.
(Well, it isn't a direct solution to your problem, but here it goes.)
Most terminal don't handle reflow in resize properly. There is no right ways to do it so most don't attempt to pull all the tricks in the book to make this better. After all, for classic floating window manger, resizing isn't something you do very often. LibVTE/Gnome-terminal isn't designed for tiling WMs and has not been patched over the years to make it better.
Urxvt is probably the most common terminal for AwesomeWM (the default is xterm because it is much more commonly installed by default). It has more advanced features like tabs and transparency you expect from modern terminals. Note that some of them (tabs) are disabled by default.
Sometime using software like tmux can be used to mitigate some of the limitations of any given terminal, but it comes with limitations of its own.

Tkinter layout changes from Spyder to Command Prompt

I have built a simple GUI in tkinter that goes through an algorithm to fit Radial Velocity data. Everything works fine in Spyder, however when I try to run the file in command prompt the GUI's dimensions change drastically. This is how it is supposed to look and how it looks in Spyder. This is how it looks when it's run in command prompt. The plots that are produced show the same behavior described. I've tried setting all the windows in Tkinter so that they are unable to be resized. I'm not sure what else to try. Is there a way to fix this? I am on Windows 10 64bit, Python 3.5.4, and Spyder 3.2.5.
I found out what the problem was. It's due to the fact that Spyder automatically overrides high DPI scaling, whereas both Python.exe and Pythonw.exe do not. The solution was to check the 'Override High DPI Scaling behavior' option under the compatibility tab for both python.exe and pythonw.exe.

Resources