visclaw icon indicating copy to clipboard operation
visclaw copied to clipboard

rasterize wavefield by default

Open Thomas-Ulrich opened this issue 3 years ago • 1 comments

I would like to propose a very small enhancement to the plotting routines. Recently, I generated publication-quality figures with geoclaw. For that I needed to generate a snapshot of a tsunami simulation in a vectorized format (e.g. svg or pdf). I only needed the text and axes to be vectorized, not the wavefield. But using plotdata.print_format = 'svg' vectorized all data (and lead to a SVG file of 30Mb). Therefore, I did the following change:

diff --git a/src/python/visclaw/frametools.py b/src/python/visclaw/frametools.py
index 9e20d52..dd6f127 100644
--- a/src/python/visclaw/frametools.py
+++ b/src/python/visclaw/frametools.py
@@ -791,6 +791,7 @@ def plotitem2(framesoln, plotitem, current_data, stateno):
             pcolor_cmd += ", edgecolors=pp['celledges_color']"
         else:
             pcolor_cmd += ", shading='flat'"
+        pcolor_cmd += ", rasterized=True"
 
         pcolor_cmd += ", **pp['kwargs'])"

Maybe it could be nice to integrate this change?

more info about the rasterization in matplotlib: https://matplotlib.org/devdocs/gallery/misc/rasterization_demo.html

Thomas-Ulrich avatar Oct 06 '21 19:10 Thomas-Ulrich

Sounds like a good idea to me.

mandli avatar Oct 06 '21 23:10 mandli