Home Forums Nazca how to get the matplolib figure? Reply To: how to get the matplolib figure?


Dear Bastien,

For matplotlib export use nd.export_plt() or alias nd.export_png().
Notice that after export the design will be cleared. So in the next example the second export would be empty:

nd.export_plt()  # will be empty

To keep the design alive you can use clear=False in the call:

nd.export_plt()  # export to png as expected

This behaviour is specifically introduced for working in Jupyter notebooks. So when you rerun a cell you do not stack design upon design by default, but if you run stuff in a sequence of cells you can set the clear=False.

Matplotlib is flexible but notoriously on the slow side. If you put a lot of frames in you color definition things will slow down.

For svg export you need to have svgwrite installed and simply use nd.export_svg(). With svg you can still edit some details for a presentation for example.

More layout export types can be added relatively easy. Each type resides in separate class that receives the same layout info from the Nazca layout engine, such as polygons, lines and annotations, but exports it to the specific format.