Skip to main content

Easy font management for matplotlib

Project description

mpl_fontkit

pypi

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

Install

pip install mpl_fontkit

Quick Start

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
_, ax = plt.subplots()
ax.set_title("Lato Font", fontdict={"style": "italic", 
                                    "weight": 700, 
                                    "size": 24})
show in plot

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.3.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

mpl_fontkit-0.3.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mpl_fontkit-0.3.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for mpl_fontkit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6580a9d6b9d6c1d0d3d306ea3e9bcc519e450c0c3c8f361778786c305a2d1500
MD5 a8e01e0535f8cb994187eb4a7b3c66a1
BLAKE2b-256 8d515d99766ee519a3fbd3142f10526753eb113008cddfd7a8cafcb08d78a559

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: mpl_fontkit-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for mpl_fontkit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a248d388eb2d8f4833ba22f3c5331f6c2124329130472029fae805d99202017f
MD5 296078f82e30bfbae7637d15bcd0bb61
BLAKE2b-256 b918de5292414d27a98c5534c776200a8342bb25ff021162d1548ed32c28713f

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