Skip to content

Instantly share code, notes, and snippets.

Avatar

Will Thompson sefffal

View GitHub Profile
@hugke729
hugke729 / rasterize_and_save.py
Last active Sep 23, 2021
Simplify export of matplotlib figures when both raster and vector components are desired in output
View rasterize_and_save.py
# A function to rasterize components of a matplotlib figure while keeping
# axes, labels, etc as vector components
# https://brushingupscience.wordpress.com/2017/05/09/vector-and-raster-in-one-with-matplotlib/
from inspect import getmembers, isclass
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
def rasterize_and_save(fname, rasterize_list=None, fig=None, dpi=None,