Skip to main content

Easy font management for Matplotlib.

Project description

mpl_fontkit

pypi

  • Use font from google fonts
  • Use icon from font awesome
  • Set the font and use it easily
  • Helpful error message to get your font name right

Install

pip install mpl_fontkit

Quick Start

Install Google Fonts

import mpl_fontkit as fk

# https://fonts.google.com/specimen/Lato?query=Lato
fk.install("Lato")

If the font does not available in matplotlib, this will download from Google and add it to matplotlib.

To check available styles for a font

fk.font_table("Lato")

And then you are ready to use it in your plots

import matplotlib.pyplot as plt
plt.text("Lato Font", fontdict={"style": "italic", "weight": 700, "size": 24})
show in plot

Install Font Awesome

To install font awesome and use it in your plot.

fk.install_fontawesome()

plt.text(.5, .5, "\uf58b\uf005\uf59b", fontfamily="Font Awesome 6 Free")

The font awesome is available as Font Awesome 6 Free and Font Awesome 6 Brands, the name of icon is encoded as unicode.

You can search for icons and get the unicode here.

fontawesome showcase

Set a font globally

To set a font manually. This will update the rcParams for you.

import mpl_fontkit as fk

fk.set_font("Lato")

Most of the time when you can't get the font to work simply because the font name is not the same as the file name. You can just type a fuzzy name, we will try to find a similar name and show you in the error message.

import mpl_fontkit as fk

fk.set_font("Lat")
LookupError: Cannot find Lat, do you mean: Lato. 
    Use `.list_fonts()` to list all the available fonts.

Get available fonts

fk.list_fonts()
['Agency FB',
 'Algerian',
 'Arial',
 'Arial Rounded MT Bold',
 'Bahnschrift',
 'Baskerville Old Face',
 'Bauhaus 93',
 ...]
 

What fonts look like?

Show one font

fk.show("Lato")

Show all fonts at once

fk.show_fonts()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpl_fontkit-0.5.0.tar.gz (46.4 kB view details)

Uploaded Source

Built Distribution

mpl_fontkit-0.5.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file mpl_fontkit-0.5.0.tar.gz.

File metadata

  • Download URL: mpl_fontkit-0.5.0.tar.gz
  • Upload date:
  • Size: 46.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for mpl_fontkit-0.5.0.tar.gz
Algorithm Hash digest
SHA256 bac5519883b74d1be6a3bc2472cfc41e31bcdcbac1443b79a5cc6bb1cef6838d
MD5 58eddece5505d4044b489ff747d7e380
BLAKE2b-256 1416ca19988bd4c4c02bf393044585096243561fb1d136855d74011eff0efe25

See more details on using hashes here.

Provenance

File details

Details for the file mpl_fontkit-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mpl_fontkit-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81414c75b808bac4edd99a475eeb3cf40ea77b4a65beea629ea7ee4c62f7c547
MD5 8042acd45c65fb8444e1f50691ed18b6
BLAKE2b-256 cbc5619120ae8d323b7cffd4884454a0a89a4ddf3fc0a1d6c22bdcb346af6b2a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page