Precommands needed for getting better pictures/

Hey, google didn’t help me
I wanted to ask the following questions to improve my pictures

a) what command hides the grid-triangles automatically? When creating a look with multiple runs it’s exhausting to do it by hand
b) Are there any options for the horizontal bar on top?
like being vertical, having less but larger numbers (it’s pretty small with height of 5cm in a file)
c) I sometimes have that lag in exporting pictures, because the program is faster then creating+exporting the picture, I was told I should do a break before exporting it. Is there any explanation/link around how to best do it?

Thanks alot in advance and as always: great project!


personally, I would do a VTK output (NGSolve Examples) and then do everything in paraview.

Best wishes,


There visual options are exposed in the ngsolve.internal module. Most options can be changed by members of ‘viewoptions’ and ‘visoptions’, which provide write-only access to the according Tcl-Variables in the GUI.

import ngsolve.internal as ngsint ngsint.viewoptions.drawoutline=0 # triangle outline ngsint.SnapShot('image.bmp')

The color bar cannot be changed directly in appearance. Concerning the pictures: Are you using the SnapShot function like above? It should automatically block further execution until the image is exported.


Hey, will look into that when I find the time, thanks!

Thanks, is there an overview somewhere hidden for all the possibilities?

And yes, I use ngsolve.internal.SnapShot(…) and no, it doesn’t block for me and neither for a colleague, very often, the first picture is repeated in the Exports

You can check the members of the variables viewoptions and visoptions in ngsolve.internal:

>>> import ngsolve.internal
importing NGSolve-6.2.1908-6-gf77e4e6b
>>> dir(ngsolve.internal.viewoptions)
['_attributes', '_name', '_update_cmd', 'centerpoint', 'centerx', 'centery', 'centerz', 'clipping', 'colormeshsize', 'drawbadels', 'drawcolorbar', 'drawcoordinatecross', 'drawcurveproj', 'drawcurveprojedge', 'drawdomainsurf', 'drawededgenrs', 'drawededges', 'drawedgenumbers', 'drawedges', 'drawedpointnrs', 'drawedpoints', 'drawedtangents', 'drawelement', 'drawelementnumbers', 'drawfacenumbers', 'drawfilledtrigs', 'drawhexes', 'drawidentified', 'drawmetispartition', 'drawnetgenlogo', 'drawoutline', 'drawpointnumbers', 'drawprisms', 'drawpyramids', 'drawspecpoint', 'drawtets', 'drawtetsdomain', 'light', 'mat', 'shrink', 'specpointvlen', 'specpointx', 'specpointy', 'specpointz', 'stereo', 'usecentercoords', 'whitebackground']
>>> dir(ngsolve.internal.visoptions)
['_attributes', '_name', '_update_cmd', 'autoredraw', 'autoredrawtime', 'autoscale', 'clipsolution', 'deformation', 'drawfieldlines', 'drawpointcurves', 'evaluate', 'evaluatefiledescriptions', 'evaluatefilenames', 'fieldlinesfilename', 'fieldlineslength', 'fieldlinesmaxpoints', 'fieldlinesonlyonephase', 'fieldlinesphase', 'fieldlinesrandomstart', 'fieldlinesrktype', 'fieldlinesstartarea', 'fieldlinesstartareap1x', 'fieldlinesstartareap1y', 'fieldlinesstartareap1z', 'fieldlinesstartareap2x', 'fieldlinesstartareap2y', 'fieldlinesstartareap2z', 'fieldlinesstartface', 'fieldlinesthickness', 'fieldlinestolerance', 'fieldlinesvecfunction', 'gridsize', 'imaginary', 'invcolor', 'isolines', 'isosurf', 'lineartexture', 'lineplotautoscale', 'lineplotcolor', 'lineplotcurrentnum', 'lineplotdatadescr', 'lineplotfile', 'lineplotinfos', 'lineplotselected', 'lineplotselectedeval', 'lineplotselector', 'lineplotsizex', 'lineplotsizey', 'lineplotsource', 'lineplotusingx', 'lineplotusingy', 'lineplotxcoordselector', 'lineplotxmax', 'lineplotxmin', 'lineplotycoordselector', 'lineplotymax', 'lineplotymin', 'logscale', 'mmaxval', 'mminval', 'multidimcomponent', 'numfieldlines', 'numiso', 'numtexturecols', 'redrawperiodic', 'scaledeform1', 'scaledeform2', 'scalfunction', 'showclipsolution', 'showsurfacesolution', 'simulationtime', 'subdivisions', 'usetexture', 'vecfunction', 'xoffset', 'yoffset']

Note that, due to asynchronous evaluation, there is only write and no read access to these values.

Dear Matthias, dear all

Tnaks alot!
However, as an example, I ahve

ngsint.viewoptions.drawnetgenlogo=0 # this does not work
ngsint.viewoptions.drawcolorbar=0  # this does work

An additional question: After I removed the effects around my domain the Snapshot is still very very large when it comes to the ratio white space/domain. Are there any possibilities to improve this?

I just want to add, on my slides I mention Netgen/NGSolve for creating my simulations. But as written, the wide bar, the logo and cross left and right, the picture simply gets toooo wide!


drawnetgenlogo and drawcolorbar do both work as intended, but they only show effect when the scene is rerendered.
This is forced with “Redraw(blocking=True)”. Anyway, there was an issue in this function and the redraw was not triggered properly in some cases. This is fixed on the master branch. As a workaround for older versions you can use

Redraw(blocking=True, fr=1e8)

For taking screenshots I recommend the following Snapshot function, which is available since about a month:

import netgen.gui Redraw(blocking=True, fr=1e8) # workaround for ngsolve < v6.2.1910-142-gc33d83357 netgen.gui.Snapshot(w=1000,h=500, filename="myimage.png")
The advantage is that you can select the resolution/aspect ratio but you need to have numpy and pillow (python image library) installed.


Dear Martin,
redrawing with the commands now works perfectly, however

netgen.gui.Snapshot(w=600,h=800, filename="TEST_"+str(count)+".png")

gives me a black picture (with the right measurements)
Additionell ngsolve saves everything with the right file-name (except it’s black) but I get

no frame buffer 0

as a return instead of the usual return
is there a correlation?
Thanks for your time

I have the versions

ngsolve ist schon die neueste Version (6.2.1910-0~ubuntu19.04.1).

python3 -m pip install Pillow Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (5.4.1)

There seems to be an issue when calling Snapshot while the GUI is started with the netgen executable. Try running your script with ‘python3’ instead of ‘netgen’. The command ‘import netgen.gui’ also starts the graphical user interface.

and it is solved! THANK you so much!