PGF fonts

import matplotlib.pyplot as plt
plt.rcParams.update({
    "font.family": "serif",
    # Use LaTeX default serif font.
    "font.serif": [],
    # Use specific cursive fonts.
    "font.cursive": ["Comic Neue", "Comic Sans MS"],
})

fig, ax = plt.subplots(figsize=(4.5, 2.5))

ax.plot(range(5))

ax.text(0.5, 3., "serif")
ax.text(0.5, 2., "monospace", family="monospace")
ax.text(2.5, 2., "sans-serif", family="DejaVu Sans")  # Use specific sans font.
ax.text(2.5, 1., "comic", family="cursive")
ax.set_xlabel("µ is not $\\mu$")

fig.tight_layout(pad=.5)

fig.savefig("pgf_fonts.pdf")
fig.savefig("pgf_fonts.png")

Related articles

matplotlib gridspec

This example demonstrates the use of `.pyplot.subplot2grid` to generate subplots.  Using `.GridSpec`, as demonstrated in :doc:`/gallery/userdemo/demo_gridspec03` is generally preferred

custom boxstyle

This example demonstrates the implementation of a custom `.BoxStyle`. Custom `.ConnectionStyle`\s and `.ArrowStyle`\s can be similarly defined.

connection style

When creating an annotation using `~.Axes.annotate`, the arrow shape can be controlled via the *connectionstyle* parameter of *arrowprops*. For further details see the description of `.FancyArrowPatch`.

matplotlib connect

ConnectionPatch` can be used to draw a line (possibly with arrow head) between points defined in different coordinate systems and/or axes.

annotate tex arrow

import numpy as np import matplotlib.pyplot as plt # Fixing random state for reproducibility np.random.seed(19680801)

matplotlib annotate explain

import matplotlib.pyplot as plt import matplotlib.patches as mpatches fig, axs = plt.subplots(2, 2) x1, y1 = 0.3, 0.3 x2, y2 = 0.7, 0.7

matplotlib anchored box04

from matplotlib.patches import Ellipse import matplotlib.pyplot as plt from matplotlib.offsetbox import (AnchoredOffsetbox, DrawingArea, HPacker, TextArea)

sanic request stream

from sanic import Sanic from sanic.blueprints import Blueprint from sanic.response import stream, text from sanic.views import HTTPMethodView from sanic.views import stream as stream_decorator

amending request object

from random import randint from sanic import Sanic from sanic.response import text app = Sanic("Example")

authorized sanic

# -*- coding: utf-8 -*- from functools import wraps from sanic import Sanic from sanic.response import json