Skip to content

Poor on-screen font antialiasing/smoothing in mplcairo #55

Open
@AgilentGCMS

Description

@AgilentGCMS

I'm trying to switch to using the mplcairo backend because it does certain things better than the MacOSX backend, especially when colormaps have transparency. However, I've noticed that the font smoothing, at least for plots displayed on the screen, is noticeably poorer. The code below offers a MWE:

import numpy as np
from matplotlib import pyplot as plt

fig = plt.figure()
plt.plot(np.linspace(0,1,10), np.linspace(0,1,10), '-o')
plt.setp(plt.gca().get_xticklabels(), size=14)
plt.setp(plt.gca().get_yticklabels(), size=14)

With the mplcairo backend, the tick labels look jagged and not smooth, as below.
Screenshot 2023-12-28 at 4 32 03 PM
Whereas with the MacOSX backend gives me noticeably smoother fonts.
Screenshot 2023-12-28 at 4 33 00 PM

Everything is identical for the production of the two figures except the backend, which I switch in .matplotlibrc. Am I missing something? Is there a way to get mplcairo to render fonts with proper smoothing?

import mplcairo
mplcairo.get_versions()
{'python': '3.11.6 (main, Oct 12 2023, 21:46:57) [Clang 15.0.0 (clang-1500.0.40.1)]',
 'mplcairo': '0.5.post32+ge771c74',
 'matplotlib': '3.8.0',
 'cairo': '1.17.6 @ /Users/sbasu1/packages/macports/lib/libcairo.2.dylib',
 'freetype': '2.13.2 @ /Users/sbasu1/packages/macports/lib/libfreetype.6.dylib',
 'pybind11': '2.11.1',
 'raqm': None,
 'harfbuzz': None}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions