{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Math fontfamily\n\nA simple example showcasing the new *math_fontfamily* parameter that can\nbe used to change the family of fonts for each individual text\nelement in a plot.\n\nIf no parameter is set, the global value\n:rc:`mathtext.fontset` will be used.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nfig, ax = plt.subplots(figsize=(6, 5))\n\n# A simple plot for the background.\nax.plot(range(11), color=\"0.9\")\n\n# A text mixing normal text and math text.\nmsg = (r\"Normal Text. $Text\\ in\\ math\\ mode:\\ \"\n       r\"\\int_{0}^{\\infty } x^2 dx$\")\n\n# Set the text in the plot.\nax.text(1, 7, msg, size=12, math_fontfamily='cm')\n\n# Set another font for the next text.\nax.text(1, 3, msg, size=12, math_fontfamily='dejavuserif')\n\n# *math_fontfamily* can be used in most places where there is text,\n# like in the title:\nax.set_title(r\"$Title\\ in\\ math\\ mode:\\ \\int_{0}^{\\infty } x^2 dx$\",\n             math_fontfamily='stixsans', size=14)\n\n# Note that the normal text is not changed by *math_fontfamily*.\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}