Vector and raster in one with Matplotlib

Vector images are great, except when they shouldn’t be vector. Figures with intricate detail can actually benefit from being rasterized. This can reduce file size and help the figure load more quickly. Python’s Matplotlib has an option to rasterize certain elements, but it doesn’t always work as simply as expected.

This post describes a function that (i) lets you rasterize any chosen elements when you export the figure and (ii) overcomes problems with the current implementation of rasterizing objects with Matplotlib.

Continue reading “Vector and raster in one with Matplotlib”

Know your image file formats

Images come in a variety of file types: jpg, png, pdf, eps, svg, tif, bmp, and countless other lesser-known ones. Each have their pros and cons, but they can be divided into two types: vector and raster. In science, we generally want vector images, unless we are dealing with photos.

Continue reading “Know your image file formats”

Using Inkscape for scientific figures, posters, and presentations

If I could offer only one piece of advice to any scientist on how to improve the figures and presentations they produce, it would be ‘Learn how to use Inkscape’. If you ended up here by searching for “Inkscape scientists” or some variant of that, then what follows is just confirmation that you’re looking for the right thing.

Inkscape is a cross-platform, open-source vector graphics editor. Let’s break down all those adjectives to see how they help:

Continue reading “Using Inkscape for scientific figures, posters, and presentations”