Change visualization options from the Python code

Is there an option to change visualization settings from the code in Python? Every time I run my simulation I always have to go through View > Viewing options > Mesh > Show filled triangles and then View > Solution data >… and more. Is there a way to set this up in the code?

From ngsolve.internal you can import viewoptions and visoptions that let you change these settings. See in the code what is available. For example to set show filled triangles to off you have to do

from ngsolve.internal import viewoptions
viewoptions.drawfilledtrigs = 0
1 Like

Thank you @christopher, this is what I was looking for. Could you help me to figure out what am I supposed to assign to the scalar function attribute visoptions.scalfunction? Passing a function name as a string or a variable name doesn’t work.

think it should be “name:i” for the i-th component of a function, starting counting from one. Here is the code processing the variables:

Thank you for the answer @joachim, but unfortunately it doesn’t work.

here is a complete example, you can select u, and components of the gradient.
best, Joachim (509 Bytes)