-
Notifications
You must be signed in to change notification settings - Fork 156
Saving curves and surfaces from the command line
NURBS-Python (geomdl) v4.0 comes with a nice feature which allows users to save curves and surfaces without opening the figure window. Just to note, export capabilities vary between the visualization modules due to their dependencies. For isntance, VisMPL
uses Matplotlib and it can export the plot as an image file (or as a PDF file) directly, whereas VisPlotly
uses Plotly for Python and it generates a HTML file which allows you to download the image after opening the HTML file.
In order to test this feature, I used the following software:
- CentOS v7.5.1804 minimal installation (no X Window System)
- Python v2.7.5
- Matplotlib 1.2.0 installed via
yum install python-matplotlib
In simple words, I followed this StackOverflow answer: https://stackoverflow.com/a/4935945
- Create
.matplotlib
directory in your home directory - Create
matplotlibrc
file inmatplotlib
directory - Add
backend: Agg
insidematplotlibrc
file
or alternatively, you may type the following:
cd; mkdir .matplotlib; echo "backend: Agg" >> .matplotlib/matplotlibrc
There are a bunch of examples on the Examples Repository but the only necessary change is updating the keyword arguments of the render()
method (docs for Curve class, docs for Surface class)
Assuming that you have successfully generated your curve/surface object and the instance is stored in the variable mynurbs
. To save the plots, you may update your render()
call like this:
mynurbs.render(filename="file_name_to_save.png", plot=False)
You can configure the resolution and other settings using VisConfig
class (documentation).