I was comparing two simple graphs I got as the output from a python file(using matplotlib) in VSC 1.59.1. I faced these issues:
-->I can open only one figure of graph from a single file at a time. I cannot run another .py file unless I close the graph for first .py file.
-->So I dragged two files in the form of grid.
-->I Opt for zen mode.
-->And finally tried to run the file in interactive window but in that case I cannot see my other file.
-->So does this mean that I need to opt for split down to see my both the files and their respective graph figure in interactive window ?
Please help!
Thanks in advance!
Here if you compare two graphs files and see two figures in your interactive window you need to split the terminal and run two python files separately in zen mode.
Spilt Terminal
Compare two graphs
Related
I am using Jupyter notebook on my laptop (the version coming with Anaconda) to perform some sensitivity analysis.
I use plotly to display the results and I like the interactive features that it has.
However, when I am trying to display more than 7/8 interactive plots on the same notebook, some plots disappears and the output cells of those plots go crazy (see picture attached).
Issue with plotly
A solution I found was to disable the interactive feature at least for some of the plots, changing the diplay mode in config as:
config = {'staticPlot': True}
fig.show(config=config)
This method works, however, I like the feature and I was wondering if there was a solution that does not imply disabling the interactive view.
I read about this post where they say it might be a memory issue (even though their graphs are going blank while mine are behaving crazy):
Plotly: How to prevent graphs from going blank when there are too many interactive plots?
However I did not manage to find/change the jupyter configuration file, maybe because I installed it via Anaconda?
I was also wondering if someone experienced exactly the same or there might be a simpler solution to this issue.
Thanks a lot in advance
I believe that in the second link the config file should be generated if not existing.
You can also try changing to gl rendering:
https://plotly.com/python/webgl-vs-svg/
I am using the Python Interactive tab (similar to Jupyter notebooks) in Microsoft Visual Studio Code.
When I plot an image, I am unable to save it directly from the editor. There's no option to save it directly with the mouse, or to save it directly from the interface.
Is there a way to save it from the interface or should I only use matplotlib's savefig method?
In my version (1.47.3) I can double click the image, which opens it in a separate tab for inspection.
One of the buttons in this tab is a save icon, which allows you to save the image in a format that depends on the file ending you choose. I've tried .png, but couldn't find an option to change resolution. .pdf or .svg saves it losslessly as vector graphic.
In the image below you can see what it looks like for me. (on Ubuntu)
Not fully sure if this counts as a full answer here on Stack Overflow. But the answer here is that we don't have a way to do this currently. You can highlight it in the interactive window and Ctrl-C to copy it out, but even that support is rather flakey at this point. If you would like to log this issue this would be the best spot to get it on our radar:
https://github.com/Microsoft/vscode-python/issues
We keep our issues open to the public so you can track when we work on it after it's filed there.
I've created an application which after choosing some files and clicking a specific button, it generates 3 to 5 plots using matplotlib (and some uses plotly). For this GUI I used Tkinter.
When I run the .py code it works perfectly, after pressing the button a plot is shown, then after closing its window a new one is displayed and so on until finish.
I tried creating the .exe file for this application using Py2exe and PyInstaller. Both of them have the same behaviour: after pressing the button the first plot is shown, but when I close its window no one is displayed. Only after closing the Tkinter windows created (one main Frame that creates another Frame which has the buttons I click for displaying the plot) the other plots appear (the second one, then after closing its window the third one, and so on).
Any clue about this? I've tried also
import matplotlib
matplotlib.use('TkAgg')
without success. TkAgg is the one that worked for generating the .exe (had to change it in the matplotlibrc).
The code runs the following way: main_app with Tkinter functionalities, second_app with some useful functions and only one Tkinter message (if conditions satisfied) and a bunch of minor .py files that each one is a function with its own calculations and plots.
If a button from the main_app is pressed it calls one specific of these minor .py files (functions) for calculating and generating the plots.
I ran into the same problem. I was using Python 3.4 and PyInstaller 3.3, and I would try to make several plots at once but only one would show until I closed the whole executable (made with PyInstaller's --onefile option). I solved the problem by using
plt.show(block=False)
instead of
plt.show()
when plotting. This did the trick for me, hope it helps you!
I've been using the IEP from pyzo before trying out Sublime Text (ST).
There is an annoying behaviour with ST that IEP doesn't have.
In IEP, much like with Matlab or Octave, the editor and the interactive console talk to each other.
Typically if you compute some_stuff and plot it in a script, after execution of this script you can go to the console and check some values:
print some_stuff[0:10]
or modify your plot:
plt.whatever()
which will update your figure.
Also if you run your script several times with different parameters, the figure is simply updated.
However when you do so in ST, even with REPL, after execution of the script nothing is left, you can't access some_stuff[0:10] from REPL. Similarly, you can't modify your figure. And if you run your script several times with different parameters, a new figure is generated in a new window each time instead of updating the existing figure.
Is there an easy work around this? Thanks!
How about saving your figure to a file with plt.savefig("fig.png")? If you open that file with your image viewer it will be updated after running your program.
I'm trying to write a Python script for Paraview that will create a .png or .pdf screenshot file with multiple views in it. The emphasis here being the MULTIPLE VIEWS part. To be clear, I have three different windows in my Paraview display: one showing the model viewed in the XZ plane, one in the XY plane and one in the YZ plane. I'm trying to use a python script to create a single file showing all three of these views. This can be done manually by clicking File->Save Screenshot and then unchecking the Save only selected view button. I need to do this several hundred times, so clearly a script is the way to go.
I've tried using the "Start trace" option to see how this operation works, but the code it produces seems incomplete:
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()
RenderView1 = GetRenderView()
RenderView2 = GetRenderViews()[1]
RenderView3 = GetRenderViews()[2]
WriteImage(r'E:\TestFolder\TestFile_00.png', view=RenderView1)
WriteImage(r'E:\TestFolder\TestFile_01.png', view=RenderView2)
WriteImage(r'E:\TestFolder\TestFile_02.png', view=RenderView3)
Render()
When I run something similar to this it just produces three separate .png files, one for each view. Maybe these are meant to be temporary files that Paraview combines to make the finished product, but I have no idea how to combine them.
Does anyone have any experience with this problem? I've scoured the internet and the Paraview documentation, but the only examples I can find have a single view only. Any help would be much appreciated.
I'm using Paraview 3.12.0 32-bit on Windows XP
Starting with ParaView 4.2, this will directly supported as follows:
# Get the layout/tab for the active view.
aLayout = GetLayout()
SaveScreenshot("AllViewsImage.png", layout=aLayout)
You can also use Tools|Start Trace and try to save the screenshot out to get the commands to use.
I have the same problem. The workaround is to use convert command. Here is the example script:
for i in range(len(GetRenderViews())) :
RenderView = GetRenderViews()[i]
WriteImage("tmp_"+str(i)+".png",view=RenderView)
commands.getoutput("convert -border 1x1 -append tmp_*.png tmp.png")
I hope this will help.