Frequently asked questions#

What makes this project different?#

There is already a great matplotlib wrapper called seaborn. Also, pandas and xarray both offer convenient matplotlib plotting commands. How does UltraPlot compare against these tools?

  • UltraPlot, seaborn, pandas, and xarray all offer tools for generating rigid, simple, nice-looking plots from data stored in DataFrames and DataArrays (UltraPlot tries to apply labels from these objects, just like pandas and xarray).

  • UltraPlot is integrated with cartopy and basemap. You will find plotting geophysical data in UltraPlot to be much more concise than working with cartopy and basemap directly.

  • UltraPlot expands upon the seaborn tools for working with color and global settings. For example, see Colormap, PerceptualColormap, and Configurator.

  • UltraPlot expands upon matplotlib by fixing various quirks, developing a more advanced automatic layout algorithm, simplifying the process of drawing outer colorbars and legends, and much more.

  • UltraPlot is built right into the matplotlib API, thanks to special subclasses of the Figure and Axes classes, while seaborn, pandas, and xarray are meant to be used separately from the matplotlib API.

In a nutshell, UltraPlot is intended to unify the convenience of seaborn, pandas, and xarray plotting with the power and customizability of the underlying matplotlib API.

Why didn’t you add to matplotlib directly?#

Since UltraPlot is built right into the matplotlib API, you might be wondering why we didn’t contribute to the matplotlib project directly.

  • Certain features directly conflict with matplotlib. For example, UltraPlot’s tight layout algorithm conflicts with matplotlib’s tight layout by permitting fluid figure dimensions, and the new GridSpec class permits variable spacing between rows and columns and uses physical units rather than figure-relative and axes-relative units.

  • Certain features are arguably too redundant. For example, format() is convenient, but the same tasks can be accomplished with existing axes and axis “setter” methods. Also, some of the functionality of subplots() can be replicated with axes_grid1. Following TOOWTDI philosophy, these features should probably not be integrated.

Why do my inline figures look different?#

These days, most publications prefer plots saved as vector graphics [1] rather than raster graphics [2]. When you save vector graphics, the content sizes should be appropriate for embedding the plot in a document (for example, if an academic journal recommends 8-point font for plots, you should use 8-point font in your plotting code).

Most of the default matplotlib backends make low-quality, artifact-plagued jpegs. To keep them legible, matplotlib uses a fairly large default figure width of 6.5 inches (usually only suitable for multi-panel plots) and a slightly large default font size of 10 points (where most journals recommend 5-9 points). This means your figures have to be downscaled so the sizes used in your plotting code are not the sizes that appear in the document.

UltraPlot helps you get your figure sizes correct for embedding them as vector graphics inside publications. It uses a slightly smaller default font size, calculates the default figure size from the number of subplot rows and columns, and adds the journal keyword argument to Figure which can be used to employ figure dimensions from a particular journal standard. To keep the inline figures legible, UltraPlot also employs a higher quality default inline backend.