Try using all mathtext fontset in python and matplotlib.pyplot


The result (computer modern: cm) is:

Try using all mathtext fontset in python and matplotlib.pyplot

In this page, I try using all mathtext fontset in python and matplotlib.pyplot. It seems that the resulting text of \mathbb{hogehoge}, \mathrm{\mathbb{hogehgoe}}, \mathfrak{hogehoge}, \mathsf{hogehoge}, and \mathrm{\mathsf{hogehoge}} are same.

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
Check the options for rcParams['mathtext.fontset']
In [2]:
plt.rcParams['mathtext.fontset'] = 'hoge'
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~/miniconda3/envs/py36/lib/python3.6/site-packages/matplotlib/__init__.py in __setitem__(self, key, val)
    815             try:
--> 816                 cval = self.validate[key](val)
    817             except ValueError as ve:

~/miniconda3/envs/py36/lib/python3.6/site-packages/matplotlib/rcsetup.py in __call__(self, s)
     69         raise ValueError('Unrecognized %s string "%s": valid strings are %s'
---> 70                          % (self.key, s, list(six.itervalues(self.valid))))
     71 

ValueError: Unrecognized fontset string "hoge": valid strings are ['dejavusans', 'dejavuserif', 'cm', 'stix', 'stixsans', 'custom']

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-2-22b74b6e5737> in <module>()
----> 1 plt.rcParams['mathtext.fontset'] = 'hoge'

~/miniconda3/envs/py36/lib/python3.6/site-packages/matplotlib/__init__.py in __setitem__(self, key, val)
    816                 cval = self.validate[key](val)
    817             except ValueError as ve:
--> 818                 raise ValueError("Key %s: %s" % (key, str(ve)))
    819             dict.__setitem__(self, key, cval)
    820         except KeyError:

ValueError: Key mathtext.fontset: Unrecognized fontset string "hoge": valid strings are ['dejavusans', 'dejavuserif', 'cm', 'stix', 'stixsans', 'custom']
So, we have fololowing 5 (+1 for further geek person) options: 'dejavusans', 'dejavuserif', 'cm', 'stix', and 'stixsans'.

dejavuserif

In [3]:
plt.rcParams["mathtext.fontset"] = "dejavuserif"
plt.figure(figsize=(12,10))
plt.plot(range(11),color="0.9")
plt.text(0.2,9,r"$\mathrm{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,8,r"$\mathit{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,7,r"$\mathtt{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,6,r"$\mathcal{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,5,r"$\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,4,r"$\mathrm{\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.text(0.2,3,r"$\mathfrak{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,2,r"$\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,1,r"$\mathrm{\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.show()

dejavusans

In [4]:
plt.rcParams["mathtext.fontset"] = "dejavusans"
plt.figure(figsize=(12,10))
plt.plot(range(11),color="0.9")
plt.text(0.2,9,r"$\mathrm{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,8,r"$\mathit{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,7,r"$\mathtt{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,6,r"$\mathcal{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,5,r"$\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,4,r"$\mathrm{\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.text(0.2,3,r"$\mathfrak{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,2,r"$\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,1,r"$\mathrm{\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.show()

cm

In [5]:
plt.rcParams["mathtext.fontset"] = "cm"
plt.figure(figsize=(12,10))
plt.plot(range(11),color="0.9")
plt.text(0.2,9,r"$\mathrm{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,8,r"$\mathit{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,7,r"$\mathtt{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,6,r"$\mathcal{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,5,r"$\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,4,r"$\mathrm{\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.text(0.2,3,r"$\mathfrak{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,2,r"$\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,1,r"$\mathrm{\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.show()

stix

In [6]:
plt.rcParams["mathtext.fontset"] = "stix"
plt.figure(figsize=(12,10))
plt.plot(range(11),color="0.9")
plt.text(0.2,9,r"$\mathrm{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,8,r"$\mathit{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,7,r"$\mathtt{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,6,r"$\mathcal{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,5,r"$\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,4,r"$\mathrm{\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.text(0.2,3,r"$\mathfrak{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,2,r"$\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,1,r"$\mathrm{\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.show()

stixsans

In [7]:
plt.rcParams["mathtext.fontset"] = "stixsans"
plt.figure(figsize=(12,10))
plt.plot(range(11),color="0.9")
plt.text(0.2,9,r"$\mathrm{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,8,r"$\mathit{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,7,r"$\mathtt{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,6,r"$\mathcal{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,5,r"$\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,4,r"$\mathrm{\mathbb{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.text(0.2,3,r"$\mathfrak{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,2,r"$\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}$",size=23)
plt.text(0.2,1,r"$\mathrm{\mathsf{The\ quick\ red\ dog\ jumped\ over\ the\ lazy\ brown\ fox}}$",size=23)
plt.show()