FAQ: Frequently asked questions#

My version of matplotlib cannot find font XYZ#

Some fonts that Tueplots uses (e.g., Times or Roboto) must be installed on your machine before matplotlib can find them. This installation means that you need to find a .ttf file online (e.g., the Roboto family is available at Google fonts: link-to-roboto, download it, and install it. For Ubuntu, this means opening the file (with your font manager) and clicking install. There are probably many other ways to do this. Once the font is installed, delete your matplotlib cache (usually: rm ~/.cache/matplotlib -rf) and restart your notebook (not just the kernel). See also this question on Stack Overflow.

On a related note: if you want to use the Latex version of the fonts/bundles, your system must include the required tex packages. See this Stack Overflow discussion for information. You may encounter this problem when using Tueplots with a Google Colab notebook.

My fonts are not displayed as expected with plt.rc_context()#

In our experience, changing fonts works more reliably with plt.rcParams.update() than with plt.rc_context(). If someone knows why, please let us know. :)

I am still getting ‘overfull hbox’ errors in my latex code#

Even though the figure sizes delivered by Tueplots match the figure sizes in style files exactly, sometimes, figures can be a few points wider than what latex allows. Visually, this does not make any difference, but it might lead to an ‘overfull hbox’ raised by, e.g., ‘pdflatex’. This overfull hbox is not Tueplots’ fault but more due to how matplotlib draws figures:

  • The figure dimensions are optimised differently, depending on whether a user selects constrained_layout=True or tight_layout=True (or neither). Refer to the constrained layout documentation for more info.

  • Sometimes, rounding errors in the division by dpi or an ignored linewidth may lead to marginally inaccurate figure sizes. See Issue #129 for context and more explanation.

Solution: If you want to avoid this warning by any means, here are some solutions:

  • Instead of \includegraphics(<plot>), use \includegraphics[width=\textwidth](<plot>). This argument fixes the final few pixels; the visual difference is non-existent.

  • Set the rel_width in the figsizes to, e.g., rel_width=0.97 and use \includegraphics(<plot>) as usual.

  • Set the savefig.bbox argument to tight, as in:

with mpl.rc_context({'savefig.bbox': 'standard'}):
    plt.savefig("figure.pdf")

and again, see Issue #129 for more info.

My submission template requires Type 1 fonts#

Type 1 fonts are a tricky requirement; for example, because Adobe will turn off support for authoring with Type 1 fonts in January 2023 . Matplotlib cannot do Type 1 fonts but uses Type 3 as a default. There is also no way of making matplotlib use Type 1 fonts. The only options are Type 3 and Type 42 (/TrueType) fonts.

Solution: If you need a Type 1 font, using TeX typesetting usually does the trick: E.g., via bundles.icml2022(usetex=True), or fonts.icml2022_tex(). If the goal, however, is only to avoid type 3 fonts, adding plt.rcParams.update({"pdf.fonttype": 42}) to your plotting code will create a PDF with TrueType fonts. See this issue for more details.

Setting the figure size of a 3d plot cuts off labels#

This problem has been raised in Issue #143. It’s a known problem in matplotlib for example, see this issue, and tight/constrained layouts are no help.

For now, and according to this stackoverflow discussion, one possible fix is to “zoom out” by running

...
ax.set_box_aspect(None, zoom=0.85)

before plt.show() or plt.savefig(...). This solution might require adjusting some whitespaces manually.