Multithreaded patch rendering through mplcairo backend
#30
andrewdnolan
started this conversation in
General
Replies: 2 comments 8 replies
-
|
@andrewdnolan, I've got linux and osx build of |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
Interestingly enough, I've tested on import sys
import mosaic
import matplotlib
import matplotlib.pyplot as plt
import mplcairo
import tempfile
import xarray as xr
def main():
fp = "/global/cfs/cdirs/e3sm/inputdata/ocn/mpas-o/IcoswISC30E3r5/mpaso.IcoswISC30E3r5.20231120.nc"
ds = xr.open_dataset(fp).squeeze()
# create the figure and a GeoAxis
fig, ax = plt.subplots(1, 1, )
descriptor = mosaic.Descriptor(ds)
# using the `Descriptor` object we just created, make a pseudocolor plot of
# the "indexToCellID" variable, which is defined at cell centers.
collection = mosaic.polypcolor(ax, descriptor, ds.indexToCellID, antialiaseds=True)
fig.colorbar(collection, fraction=0.1, shrink=0.5, label="Cell Index");
with tempfile.NamedTemporaryFile() as fp:
fig.savefig(f"{fp.name}.png")
plt.close()
if __name__ == '__main__':
matplotlib.use("module://mplcairo.base")
if len(sys.argv) == 2:
N = int(sys.argv[1])
else:
N = 0
with mplcairo.set_options(collection_threads=N):
main() |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
mplcairopackage reimplements a complete cairo backend for Matplotlib. Of most interest to us, it provides optional multithreaded drawing of markers and path collections, which is currently the most expensive part ofmosiac.Beta Was this translation helpful? Give feedback.
All reactions