matplotlib / matplotlib/mplcairo
Poor on-screen font antialiasing/smoothing in mplcairo
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 119
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
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.
Whereas with the MacOSX backend gives me noticeably smoother fonts.
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}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Python MWE with the mplcairo and MacOSX backends, using the reported mplcairo, Matplotlib, Cairo, and FreeType versions as a reference. Compare the on-screen text rendering and investigate the backend's font-rendering path. Done means establishing whether equivalent smoothing is supported and either improving it or clearly documenting the limitation and available configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100