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”

Advertisements

Significant figures aren’t necessarily significant

Round to two significant figures is the first of what statistician Andrew Ehrenberg describes as Six Basic Rules in his Rudiments of Numeracy. It contradicts the standard rules about significant figures taught in school, but I agree with Ehrenberg.

Continue reading “Significant figures aren’t necessarily significant”

Image conversion with a right-click

Image file manipulation is typically associated with programs like Inkscape, Photoshop, or even MS Paint. A graphical user interface, however, isn’t a pre-requisite for manipulating images. Often it is overkill. Simple tasks such as resizing or converting file type can be achieved with little more than a right click (and the power of ImageMagick).

ImageMagick is a command-line, Swiss-army-knife of image manipulation. It can achieve all the usual manipulations: sharpen, rotate, resize, convert to grayscale, convert to a sketch. The list goes on… Instead of harnessing all its creative power, here I show how ImageMagick commands can be added to the right-click menu (in either Windows or Linux) to achieve simple changes without ever opening the file. Continue reading “Image conversion with a right-click”

Simplify your slides

At least 80% of scientific talks are bad. Most of these could be vastly improved by improving the slides. It may take a little extra time up front, but whose time is more precious? Yours, or the total of all the people in the audience?

Within my suggestions below, a common theme emerges: Simplify!

Continue reading “Simplify your slides”

A better web reading experience

Web pages are typically filled with numerous links, menus, and widgets that are intended to make it easy to find what you want. However, these become distracting when actually reading content online. Further, many websites appear to ignore guidelines for readability. Fortunately, there are ways to improve your own experience when reading.

Continue reading “A better web reading experience”

Matplotlib animations the easy way

Creating animations with Python’s Matplotlib is quick and easy once you know how to do it. However, when learning I found the tutorials and examples online either daunting, overly sophisticated, or lacking explanation. In many cases all I need is a quick-and-dirty script that works, rather than longer code that adheres to best practices.

Continue reading “Matplotlib animations the easy way”