Why jupyter notebook or lab doesn't show an interactive pyvista scene? - visualization

I am unable to interact with pyvista plots either on jupyter notebook or lab. I am working on a geometric problem and want to check output of the code both in graphs and text (e.g., check vertex coordinates or face normals of a mesh). I get interactive Pyvista plots if I just run the code in a py script, but it is a slow workflow and have to check print() results somewhere else.
I am adding
pl.show(jupyter_backend='pythreejs')
as the pyvista documentations suggests, but I still get a static plot. It's the same problem in VS Code, where I started. I thought it might be VS Code so I installed Jupyter notebook and jupyter lab. No success. I really appreciate any help. It's frustrating to get stuck in the first step of visually checking the output in an interactive way which is necessary for solving a geometric problem, not to mention posting it later online. Appreciate any help.

Related

PyPlot figure not shown in VS Code Jupyter "UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure."

I run Julia inside Jupyter notebook within the Microsoft Visual Studio Code IDE.
When I try to make a PyPlot plot, the figure is not shown at and instead I am seeing the following message:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
The figure will be shown when a PyPlot.display_figs() line will be added at the end of the cell code (note that the display_figs method is not exported so it needs be prepended with PyPlot).
Note that I observe this happening from time to time on some VS Code installation so I publish here this workaround so other people can easily google it.

Is there any way of scrubbing notebooks pre-save?

I work with sensitive data and need my notebook to scrub the outputs of cells before saving. I know that this is possible in Jupyter notebooks, but is this also possible in VScode Jupyter?
Here's the link to the example in the Jupyter docs, where a scrub_output_pre_save function is written and inserted into the jupyter_notebook_config.py-file.
Thanks!

Matlab openGL Warning

I'm tasked with upgrading a lot of legacy models and scripts made in an older version of Matlab/Simulink and have it running smoothly in R2018b. Among other requirements I'm not allowed to have any warnings issued upon execution of .m scripts or Simulink models. This is generally tedious but straightforward to comply.
However, there is a specific warning that Matlab does not give me hints on possible sources:
Warning: MATLAB has disabled some advanced graphics rendering features by switching to software OpenGL. For more information click here.
The link opens the Matlab Help page titled Resolving Low-Level Graphics Issues, which describes issues I'm not finding (or at least not noticing)
I do note that many scripts I run create and close figures, but this is done procedurally. I haven't been able to associate this warning with some specific function or feature. I'm working on a Windows Server machine.
Does anyone have an idea of how to narrow down which kind of function os Simulink block could cause this warning?
As datenwolf and Ander point out, the first thing to try is to update your drivers. If this doesn't work, and your only problem is that you're getting the warning but your graphics still render fine, then you have two other options to try.
First, you can simply modify your OpenGL rendering preferences using opengl. The following will set your preference to 'software' and save that setting for future sessions:
opengl('save', 'software');
Alternatively, you can just try to suppress that particular warning message. After you get the warning, issue this call to the warning function:
w = warning('query', 'last');
The w.identifier field will give you the ID for the warning message, which I believe will be 'MATLAB:hg:AutoSoftwareOpenGL' in this case. You can then add the following line to your startup.m file so that this warning is suppressed every time MATLAB is opened:
warning('off', 'MATLAB:hg:AutoSoftwareOpenGL');
Install the original vendor drivers for your GPU. The drivers that are installed by Windows by default lack full OpenGL support. Download the driver package directly from the website of Intel, AMD or NVidia, depending on what GPU you have.
If you don't have GPU, for example when running in a Virtual Machine, then you can not avoid that warning, because then Matlab has no other choice than falling back on the software OpenGL implementation that it ships with.
There's nothing you can do about that, other than making sure, that the system you're running Matlab on, does have proper OpenGL support!
It took me a long time to get it, so I'll put you here in case it helps how I managed to activate openGL in Linux:
If you haven't already (it's common for other problems), rename libstdc++ library from MATLAB:
mv _YOUR_MATLAB_ROOT_FOLDER_/sys/os/glnxa64/libstdc++.so.6 _YOUR_MATLAB_ROOT_FOLDER_/sys/os/glnxa64/libstdc++.so.6.bak
Create this link: sudo ln -s /usr/lib/x86_64-linux-gnu/dri/ /usr/lib/
Run export MESA_LOADER_DRIVER_OVERRIDE=YOUR_DRI_DRIVER;matlab -desktop -nosoftwareopeng
Your DRI Driver will be a file from /usr/lib/dri, removing "_dri" (in my case was the "radeons" driver for an AMD Vega graphic card.
Run MATLAB from a terminal using: export MESA_LOADER_DRIVER_OVERRIDE=_YOUR_DRIVER_HERE_;matlab -desktop -nosoftwareopengl. YOUR_DRIVER_HERE should be your driver, radeonsi in my case.
Check openGL with info = rendererinfo
If something went wrong, you will be able to see in the terminal which library was responsible. Executing 4) and 5) I was discovering what I had to correct, you can do the same if you have another problem that has not appeared to me.
So that it always runs correctly I put export MESA_LOADER_DRIVER_OVERRIDE=YOUR_DRI_DRIVER at the beginning of the script that runs matlab (_YOUR_MATLAB_FOLDER/bin/matlab), although I suppose it can also be set as an environment variable.
I hope this has been useful to you.

Jupyter notebook auto indentation doesn't work for scala

I have being using jupyter notebook from the anaconda distribution for quite awhile, and I have installed both Python 2 and 3, and R kernels. They all work fine.
Recently, however, after I installed scala kernel, everything works fine except for the auto indentation, i.e. the cursor always sits at the beginning of a line after the enter is hit, and this problem only occurs in scala notebook.
I have tried jupyter-scala and Apache toree. They both have this issue. This issue is troublesome, for example, when you write nested loops as you have to tab the mouse cursor to the right position on every new line.
I have tried the conventional methods such as modifying the custom.js file, and issuing the mirrorcode commands on the browser console to set the indentUnit. It has effect on Python and R notebooks but Scala notebook just won't change.
Highly appreciate your help! I have been bothered by this issue for awhile now. Thank you very much in advance!

Xming and picture rendering in Matlab

I'm using xming 6.9.0.31 on Windows XP computer to connect to Linux server and run Matlab scripts there. I have 2 configurations of xming and both have problems related to matlab output figures.
In one configuration everything works on the first script run, all figures come fine. But on the second run (of the same script) xming crashes when it outputs some figures. It might work longer if i create figures in command line, but eventually it will crash anyway, on the process of outputting new figure.
In another configuration (borrowed from andLinux installation) xming doesn't crash and is able to output figures, but only simple plots, if there is something more complicated, with a lot of data, just figure frame appears with whatever was under the figure window. The same thing happens if i actually run andLinux and connect to Matlab from there.
Seems that this is somehow related to memory. Are there any options for xming which are related to used memory? As far as i understand it'a only showing the image which was created on the server side?
If the issue is related to OpenGl setting another renderer might help.
set(gcf,'Renderer','Zbuffer')