Skip to content

Use aligned toolbar icons and updated app icon.#32095

Open
iccir wants to merge 1 commit into
matplotlib:mainfrom
iccir:fix-icons
Open

Use aligned toolbar icons and updated app icon.#32095
iccir wants to merge 1 commit into
matplotlib:mainfrom
iccir:fix-icons

Conversation

@iccir

@iccir iccir commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

PR summary

Toolbar Icon Alignment

Previously, toolbar icons were generated directly from the Font Awesome 4.7 font and exported to SVG, PDF, 24x24 PNG, and 48x48 PNG files. This approach had a few issues. Most notably, the icons were not vertically aligned. This was especially noticeable with the "home" and "subplot" icons on newer versions of macOS:

Screenshot

If we zoom in and measure, there is a 19px padding on the top of the house and only a 10px-10.5px padding on the bottom:

Screenshot

Other icons are better, but still slightly too low. Additionally, all icons have slightly-blurry edges as scaling has occurred and straight lines are no longer on pixel boundaries:

This is not a macOS-only problem - all backends suffer these alignment issues as the source SVGs/PNGs/PDFs are misaligned. Here's qtagg:

Screenshot

To solve this: I took the original icons, scaled to a target of 48x48px, and redrew them to fit on pixel boundaries. The resulting icons are both vertically aligned and sharper:

Screenshot Screenshot

App Icon

The app icon used by various backends was using an (older?) version of the matplotlib logo:

old app icon

I generated a new one based on the current logo:

new app icon

Additionally, matplotlib.png and matplotlib_large.png were 24px and 48px respectively, matching the toolbar icons. I'm not sure why 24px was chosen. As far as I can tell, Windows historically used 32px as a "standard" size and 48px for "large".

I changed matplotlib.png to be a 256px. This seems to be the maximum size for Windows and Linux when targetting high-resolution displays.

I also generated a 32px icon with slightly more contrast to use as a smaller variant:

Small icon

Here's a chart showing the file names, old size, and new size. I'm fairly sure that I updated all code paths where these files were used. I can try another approach if we need to maintain the old sizes for compatibility reasons.

Old Size New Size
matplotlib.png 24px 256px
matplotlib_large.png 48px (Removed)
matplotlib_small.png N/A 32px

make_icons.py

The tools/make_icons.py script now loads each SVG from mpl-data/images and converts it to PNGs and a PDF. PNG conversion is performed via Inkscape and optipng - the same dependencies that the documentation uses. PDF conversion is handled by pikepdf.

Due to the use of optipng and by-hand-SVG-optimization, the content size of the mpl-data directory went from ~141k to ~79k.

AI Disclosure

  • I used AI to help me create the updated make_icons.py script. I fully understand all lines of said script and was capable of coding it without any AI guidance.
  • I used AI to make changes to _backend_gtk.py. This is the one file that I'm not confident in as I'm not sure how to test my changes. Any guidance is appreciated!

PR checklist

Questions:

  • I dislike the idea of using mpl-data/images to store both the input SVG files and the output files. I'd like for the input SVG files to have more comments that would get stripped when copied to mpl-data/images. Is there a location where input assets could be stored that's not mpl-data/images? I'll need such a location for [ENH]: macOS backend should match system app icons #31895.
  • Right now, the save icon is the only one that uses a "stroked" style compared to a "filled" style. Should I change the save icon to be filled for consistency with the others?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant