From 9991b59d02061e1f6d20d96964eaa0f174381c9b Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sun, 12 Jul 2026 13:52:38 +0200 Subject: [PATCH] Speed up execution of mcplot-matplotlib (especially for big 2D matrices) --- tools/Python/mcplot/matplotlib/plotfuncs.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/Python/mcplot/matplotlib/plotfuncs.py b/tools/Python/mcplot/matplotlib/plotfuncs.py index 5b70bb220..53ab8bb45 100644 --- a/tools/Python/mcplot/matplotlib/plotfuncs.py +++ b/tools/Python/mcplot/matplotlib/plotfuncs.py @@ -211,7 +211,16 @@ def plot_single_data(node, i, n, log): #ax = Axes3D(pylab.gcf()) #pylab.contour(x,y,zvals) #ax.plot_surface(x,y,zvals) - pylab.pcolor(x,y,zvals) + # pcolormesh (QuadMesh) instead of pcolor (PolyCollection): pcolor + # builds one vector polygon per grid cell, which is dramatically + # slower to construct and render for vector output formats + # (mctest.py generates a PDF overview per test via --format=pdf), + # and produces much larger files. pcolormesh is a same-signature + # drop-in given our regularly-gridded x/y (from linspace), and + # rasterized=True has vector backends embed it as a single bitmap + # rather than thousands of individual polygons; PNG/interactive + # output is raster either way and unaffected. + pylab.pcolormesh(x, y, zvals, shading='auto', rasterized=True) pylab.colorbar() pylab.xlabel(data.xlabel, fontsize=fontsize, fontweight='bold')