{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to plot mathematical expressions and symbols in vcs? \n", "\n", "VCS can take advantage of matolotlib's text capabilites, this Jupyter notebook essentially shows how to implement in vcs [the following matplolib tutorial](https://matplotlib.org/users/mathtext.html)\n", "\n", "You can use a subset TeX markup in any vcs text string by placing it inside a pair of dollar signs ($).\n", "\n", "Note that you do not need to have TeX installed, since matplotlib ships its own TeX expression parser, layout engine and fonts. The layout engine is a fairly direct adaptation of the layout algorithms in Donald Knuth’s TeX, so the quality is quite good.\n", "\n", "Any text element can use math text. You should use raw strings (precede the quotes with an 'r'), and surround the math text with dollar signs ($), as in TeX. Regular text and mathtext can be interleaved within the same string. Mathtext can use DejaVu Sans (default), DejaVu Serif, the Computer Modern fonts (from (La)TeX), STIX fonts (with are designed to blend well with Times), or a Unicode font that you provide. The mathtext font can be selected with the customization variable mathtext.fontset [see Customizing matplotlib](https://matplotlib.org/users/customizing.html#customizing-matplotlib)\n", "\n", "Simple example\n", "\n", "The CDAT software was developed by LLNL. This tutorial was written by Charles Doutriaux. This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.\n", "\n", "[Download the Jupyter Notebook](Mathematical_Expressions_and_Symbols.ipynb)" ] }, { "cell_type": "markdown", "metadata": { "toc": true }, "source": [ "

Table of Contents

\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import vcs\n", "x=vcs.init(bg=True, geometry=(800,60))\n", "# Convenience function for later in the script\n", "def update():\n", " x.clear()\n", " return x.plot(text)\n", "\n", "text = vcs.createtext()\n", "# Position string\n", "text.x = [.5]\n", "text.y = [.5]\n", "text.halign = \"center\"\n", "text.valign = \"half\"\n", "text.height = 250\n", "text.string = \"alpha > beta\"\n", "x.plot(text)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "produces “alpha > beta”.\n", "\n", "Whereas this:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# mathematical text\n", "text.string = r\"$\\alpha > \\beta$\"\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Note**\n", "\n", "Mathtext should be placed between a pair of dollar signs (\\$). To make it easy to display monetary values, e.g., “$100.00”, if a single dollar sign is present in the entire string, it will be displayed verbatim as a dollar sign. This is a small change from regular TeX, where the dollar sign in non-math text would have to be escaped (‘\\$’)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Note**\n", "\n", "While the syntax inside the pair of dollar signs (\\$) aims to be TeX-like, the text outside does not. In particular, characters such as:\n", "```\n", "# $ % & ~ _ ^ \\ { } ( ) [ ]\n", "```\n", "have special meaning outside of math mode in TeX. Therefore, these characters will behave differently depending on the rcParam text.usetex flag. See the usetex tutorial for more information." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Subscripts and superscripts\n", "[Back to Top](#top)\n", "\n", "\n", "To make subscripts and superscripts, use the '_' and '^' symbols:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r\"$\\alpha_i > \\beta_i$\"\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Some symbols automatically put their sub/superscripts under and over the operator." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r'$\\sum_{i=0}^\\infty x_i$'\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fractions, binomials and stacked numbers\n", "\n", "[Back to Top](#top)\n", "\n", "Fractions, binomials and stacked numbers can be created with the \\frac{}{}, \\binom{}{} and \\stackrel{}{} commands, respectively:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string=r'$\\frac{3}{4} \\binom{3}{4} \\stackrel{3}{4}$'\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Fractions can be arbitrarily nested:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string=r'$\\frac{5 - \\frac{1}{x}}{4}$'\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that special care needs to be taken to place parentheses and brackets around fractions. Doing things the obvious way produces brackets that are too small:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r'$(\\frac{5 - \\frac{1}{x}}{4})$'\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The solution is to precede the bracket with \\left and \\right to inform the parser that those brackets encompass the entire object:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r'$\\left(\\frac{5 - \\frac{1}{x}}{4}\\right)$'\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Radicals\n", "\n", "[Back to Top](#top)\n", "\n", "Radicals can be produced with the \\sqrt[]{} command. For example:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r'$\\sqrt{2}$'\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Any base can (optionally) be provided inside square brackets. Note that the base must be a simple expression, and can not contain layout commands such as fractions or sub/superscripts:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r'$\\sqrt[3]{x}$'\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fonts\n", "\n", "[Back to Top](#top)\n", "\n", "The default font is italics for mathematical symbols." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Note**\n", "This default can be changed using the mathtext.default rcParam. This is useful, for example, to use the same font as regular non-math text for math text, by setting it to regular.\n", "To change fonts, e.g., to write “sin” in a Roman font, enclose the text in a font command:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r'$s(t) = \\mathcal{A}\\mathrm{sin}(2 \\omega t)$'\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "More conveniently, many commonly used function names that are typeset in a Roman font have shortcuts. So the expression above could be written as follows:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r'$s(t) = \\mathcal{A}\\sin(2 \\omega t)$'\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here “s” and “t” are variable in italics font (default), “sin” is in Roman font, and the amplitude “A” is in calligraphy font. Note in the example above the caligraphy A is squished into the sin. You can use a spacing command to add a little whitespace between them:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r\"$s(t) = \\mathcal{A}\\/\\sin(2 \\omega t)$\"\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The choices available with all fonts are:\n", "\n", "|Command|Result |\n", "|:------|------:|\n", "| \\mathrm{Roman} | $\\mathrm{Roman}$ |\n", "|\\mathit{Italic}| $\\mathit{Italic}$ |\t\n", "|\\mathtt{Typewriter} | $\\mathtt{Typewriter}$ |\t\n", "|\\mathcal{CALLIGRAPHY} | $\\mathcal{CALLIGRAPHY}$ |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When using the STIX fonts, you also have the choice of:\n", "\n", "|Command|Result|\n", "|:------|------:|\n", "|\\mathbb{blackboard}| $\\mathbb{blackboard}$ |\n", "|\\mathrm{\\mathbb{blackboard}}| $\\mathrm{\\mathbb{blackboard}}$ |\n", "|\\mathfrak{Fraktur}| $\\mathfrak{Fraktur}$ |\n", "|\\mathsf{sansserif}| $\\mathsf{sansserif}$ |\n", "|\\mathrm{\\mathsf{sansserif}}| $\\mathrm{\\mathsf{sansserif}}$ |\n", "|\\mathcircled{circled}| $\\mathcircled{circled}$ |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Additionally, you can use \\mathdefault{...} or its alias \\mathregular{...} to use the font used for regular text outside of mathtext. There are a number of limitations to this approach, most notably that far fewer symbols will be available, but it can be useful to make math expressions blend well with other text in the plot." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Custom fonts\n", "\n", "[Back to Top](#top)\n", "\n", "mathtext also provides a way to use custom fonts for math. This method is fairly tricky to use, and should be considered an experimental feature for patient users only. By setting the rcParam mathtext.fontset to custom, you can then set the following parameters, which control which font file to use for a particular set of math characters.\n", "\n", "|Parameter|Corresponds to|\n", "|:--------|--------:|\n", "|mathtext.it|\\mathit{} or default italic|\n", "|mathtext.rm|\\mathrm{} Roman (upright)|\n", "|mathtext.tt|\\mathtt{} Typewriter (monospace)|\n", "|mathtext.bf|\\mathbf{} bold italic|\n", "|mathtext.cal|\\mathcal{} calligraphic|\n", "|mathtext.sf|\\mathsf{} sans-serif|\n", "\n", "Each parameter should be set to a fontconfig font descriptor (as defined in the yet-to-be-written font chapter).\n", "\n", "The fonts used should have a Unicode mapping in order to find any non-Latin characters, such as Greek. If you want to use a math symbol that is not contained in your custom fonts, you can set the rcParam mathtext.fallback_to_cm to True which will cause the mathtext system to use characters from the default Computer Modern fonts whenever a particular character can not be found in the custom font.\n", "\n", "Note that the math glyphs specified in Unicode have evolved over time, and many fonts may not have glyphs in the correct place for mathtext." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Accents\n", "\n", "An accent command may precede any symbol to add an accent above it. There are long and short forms for some of them.\n", "\n", "|Command|Result|\n", "|:------|------:|\n", "|\\acute a or \\'a| $\\acute a$ |\t\n", "|\\bar a| $\\bar a$|\n", "|\\breve a| $\\breve a$|\n", "|\\ddot a or \\\"a| $\\ddot a$|\n", "|\\dot a or \\.a|$\\dot a$|\n", "|\\grave a or \\`a| $\\grave a$|\n", "|\\hat a or \\^a|$\\hat a$|\n", "|\\tilde a or \\~a|$\\tilde a$|\n", "|\\vec a| $\\vec a$|\n", "|\\overline{abc}| $\\overline{abc}$|\n", "\n", "In addition, there are two special accents that automatically adjust to the width of the symbols below:\n", "\n", "|Command|Result|\n", "|:------|------:|\n", "|\\widehat{xyz}| $\\widehat{xyz}$|\n", "|\\widetilde{xyz}| $\\widetilde{xyz}$ |\n", "\n", "Care should be taken when putting accents on lower-case i’s and j’s. Note that in the following \\imath is used to avoid the extra dot over the i:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text.string = r\"$\\hat i\\ \\ \\hat \\imath$\"\n", "update()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Symbols\n", "\n", "[Back to Top](#top)\n", "\n", "You can also use a large number of the TeX symbols, as in \\infty, \\leftarrow, \\sum, \\int." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lower-case Greek\n", "\n", "|Command|Result|\n", "|:------|------:|\n", "|\\alpha |$\\alpha$|\n", "|\\beta| $\\beta$|\n", "|\\chi| $\\chi$|\n", "|\\delta| $\\delta$|\n", "|\\digamma| $\\digamma$|\n", "|\\epsilon |$\\epsilon$|\n", "|\\eta |$\\eta$|\n", "|\\gamma| $\\gamma$|\n", "|\\iota |$\\iota$ |\n", "|\\kappa |$\\kappa$|\n", "|\\lambda |$\\lambda$|\n", "|\\mu |$\\mu$|\n", "|\\nu| $\\nu$|\n", "|\\omega |$\\omega$|\n", "|\\phi| $\\phi$|\n", "|\\pi |$\\pi$|\n", "|\\psi| $\\psi$|\n", "|\\rho |$\\rho$|\n", "|\\sigma |$\\sigma$|\n", "|\\tau| $\\tau$|\n", "|\\theta |$\\theta$|\n", "|\\upsilon| $\\upsilon$|\n", "|\\varepsilon |$\\varepsilon$|\n", "|\\varkappa |$\\varkappa$|\n", "|\\varphi| $\\varphi$|\n", "|\\varpi| $\\varpi$|\n", "|\\varrho |$\\varrho$|\n", "|\\varsigma| $\\varsigma$|\n", "|\\vartheta| $\\vartheta$|\n", "|\\xi| $\\xi$|\n", "|\\zeta |$\\zeta$|\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Upper-case Greek\n", "\n", "|Command|Result|\n", "|:------|------:|\n", "|\\Delta | $\\Delta$| \n", "|\\Gamma |$\\Gamma$ |\n", "|\\Lambda| $\\Lambda$ | \n", "|\\Omega| $\\Omega$| \n", "|\\Phi |$\\Phi$ | \n", "|\\Pi| $\\Pi$|\n", "|\\Psi |$\\Psi$ |\n", "|\\Sigma |$\\Sigma$ |\n", "|\\Theta |$\\Theta$ |\n", "|\\Upsilon| $\\Upsilon$| \n", "|\\Xi |$\\Xi$ |\n", "|\\mho |$\\mho$|\n", "|\\nabla |$\\nabla$|\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Hebrew\n", "\n", "|Command|Result|\n", "|:------|------:|\n", "|\\aleph| $\\aleph$ |\n", "|\\beth |$\\beth$ |\n", "|\\daleth |$\\daleth$ |\n", "|\\gimel| $\\gimel$|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Delimiters\n", "\n", "|Command|Result|\n", "|:------|------:|\n", "|/ |$/$ |\n", "|[ |$[$ |\n", "|\\Downarrow |$\\Downarrow$ |\n", "|\\Uparrow |$\\Uparrow$ |\n", "|\\Vert| $\\Vert$|\n", "|\\backslash |$\\backslash$|\n", "|\\downarrow| $\\downarrow$ |\n", "|\\langle |$\\langle$ |\n", "|\\lceil |$\\lceil$ |\n", "|\\lfloor| $\\lfloor$| \n", "|\\llcorner |$\\llcorner$|\n", "|\\lrcorner| $\\lrcorner$|\n", "|\\rangle |$\\rangle$ |\n", "|\\rceil |$\\rceil$ |\n", "|\\rfloor |$\\rfloor$| \n", "|\\ulcorner |$\\ulcorner$ |\n", "|\\uparrow| $\\uparrow$ |\n", "|\\urcorner| $\\urcorner$|\n", "|\\vert| $\\vert$ |\n", "|\\{| $\\{$ |\n", "|\\| | $\\|$ |\n", "|\\}| $\\}$ |\n", "|]| $]$ |\n", "|$|$| $|$|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Big symbols\n", "\n", "|Command|Result|\n", "|:------|------:|\n", "|\\bigcap| $\\bigcap$ | \n", "|\\bigcup |$\\bigcup$ |\n", "|\\bigodot |$\\bigodot$| \n", "|\\bigoplus |$\\bigoplus$| \n", "|\\bigotimes |$\\bigotimes$|\n", "|\\biguplus |$\\biguplus$ |\n", "|\\bigvee |$\\bigvee$ |\n", "|\\bigwedge| $\\bigwedge$| \n", "|\\coprod |$\\coprod$ |\n", "|\\int |$\\int$|\n", "|\\oint |$\\oint$|\n", "|\\prod |$\\prod$| \n", "|\\sum |$\\sum$|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Standard function names\n", "\n", "|Command|Result|\n", "|:-------|-------:|\n", "| \\Pr | $\\Pr$ |\n", "| \\arccos | $\\arccos$ |\n", "| \\arcsin | $\\arcsin$ |\n", "| \\arctan | $\\arctan$ |\n", "| \\arg | $\\arg$ |\n", "| \\cos | $\\cos$ |\n", "| \\cosh | $\\cosh$ |\n", "| \\cot | $\\cot$ |\n", "| \\coth | $\\coth$ |\n", "| \\csc | $\\csc$ |\n", "| \\deg | $\\deg$ |\n", "| \\det | $\\det$ |\n", "| \\dim | $\\dim$ |\n", "| \\exp | $\\exp$ |\n", "| \\gcd | $\\gcd$ |\n", "| \\hom | $\\hom$ |\n", "| \\inf | $\\inf$ |\n", "| \\ker | $\\ker$ |\n", "| \\lg | $\\lg$ |\n", "| \\lim | $\\lim$ |\n", "| \\liminf | $\\liminf$ |\n", "| \\limsup | $\\limsup$ |\n", "| \\ln | $\\ln$ |\n", "| \\log | $\\log$ |\n", "| \\max | $\\max$ |\n", "| \\min | $\\min$ |\n", "| \\sec | $\\sec$ |\n", "| \\sin | $\\sin$ |\n", "| \\sinh | $\\sinh$ |\n", "| \\sup | $\\sup$ |\n", "| \\tan | $\\tan$ |\n", "| \\tanh | $\\tanh$ |\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Binary Opertions and Relationships Symbols\n", "\n", "|Command|Result|\n", "|:-------|-------:|\n", "| \\Bumpeq | $\\Bumpeq$ |\n", "| \\Cap | $\\Cap$ |\n", "| \\Cup | $\\Cup$ |\n", "| \\Doteq | $\\Doteq$ |\n", "| \\Join | $\\Join$ |\n", "| \\Subset | $\\Subset$ |\n", "| \\Supset | $\\Supset$ |\n", "| \\Vdash | $\\Vdash$ |\n", "| \\Vvdash | $\\Vvdash$ |\n", "| \\approx | $\\approx$ |\n", "| \\approxeq | $\\approxeq$ |\n", "| \\ast | $\\ast$ |\n", "| \\asymp | $\\asymp$ |\n", "| \\backepsilon | $\\backepsilon$ |\n", "| \\backsim | $\\backsim$ |\n", "| \\backsimeq | $\\backsimeq$ |\n", "| \\barwedge | $\\barwedge$ |\n", "| \\because | $\\because$ |\n", "| \\between | $\\between$ |\n", "| \\bigcirc | $\\bigcirc$ |\n", "| \\bigtriangledown | $\\bigtriangledown$ |\n", "| \\bigtriangleup | $\\bigtriangleup$ |\n", "| \\blacktriangleleft | $\\blacktriangleleft$ |\n", "| \\blacktriangleright | $\\blacktriangleright$ |\n", "| \\bot | $\\bot$ |\n", "| \\bowtie | $\\bowtie$ |\n", "| \\boxdot | $\\boxdot$ |\n", "| \\boxminus | $\\boxminus$ |\n", "| \\boxplus | $\\boxplus$ |\n", "| \\boxtimes | $\\boxtimes$ |\n", "| \\bullet | $\\bullet$ |\n", "| \\bumpeq | $\\bumpeq$ |\n", "| \\cap | $\\cap$ |\n", "| \\cdot | $\\cdot$ |\n", "| \\circ | $\\circ$ |\n", "| \\circeq | $\\circeq$ |\n", "| \\coloneq | $\\coloneq$ |\n", "| \\cong | $\\cong$ |\n", "| \\cup | $\\cup$ |\n", "| \\curlyeqprec | $\\curlyeqprec$ |\n", "| \\curlyeqsucc | $\\curlyeqsucc$ |\n", "| \\curlyvee | $\\curlyvee$ |\n", "| \\curlywedge | $\\curlywedge$ |\n", "| \\dag | $\\dag$ |\n", "| \\dashv | $\\dashv$ |\n", "| \\ddag | $\\ddag$ |\n", "| \\diamond | $\\diamond$ |\n", "| \\div | $\\div$ |\n", "| \\divideontimes | $\\divideontimes$ |\n", "| \\doteq | $\\doteq$ |\n", "| \\doteqdot | $\\doteqdot$ |\n", "| \\dotplus | $\\dotplus$ |\n", "| \\doublebarwedge | $\\doublebarwedge$ |\n", "| \\eqcirc | $\\eqcirc$ |\n", "| \\eqcolon | $\\eqcolon$ |\n", "| \\eqsim | $\\eqsim$ |\n", "| \\eqslantgtr | $\\eqslantgtr$ |\n", "| \\eqslantless | $\\eqslantless$ |\n", "| \\equiv | $\\equiv$ |\n", "| \\fallingdotseq | $\\fallingdotseq$ |\n", "| \\frown | $\\frown$ |\n", "| \\geq | $\\geq$ |\n", "| \\geqq | $\\geqq$ |\n", "| \\geqslant | $\\geqslant$ |\n", "| \\gg | $\\gg$ |\n", "| \\ggg | $\\ggg$ |\n", "| \\gnapprox | $\\gnapprox$ |\n", "| \\gneqq | $\\gneqq$ |\n", "| \\gnsim | $\\gnsim$ |\n", "| \\gtrapprox | $\\gtrapprox$ |\n", "| \\gtrdot | $\\gtrdot$ |\n", "| \\gtreqless | $\\gtreqless$ |\n", "| \\gtreqqless | $\\gtreqqless$ |\n", "| \\gtrless | $\\gtrless$ |\n", "| \\gtrsim | $\\gtrsim$ |\n", "| \\in | $\\in$ |\n", "| \\intercal | $\\intercal$ |\n", "| \\leftthreetimes | $\\leftthreetimes$ |\n", "| \\leq | $\\leq$ |\n", "| \\leqq | $\\leqq$ |\n", "| \\leqslant | $\\leqslant$ |\n", "| \\lessapprox | $\\lessapprox$ |\n", "| \\lessdot | $\\lessdot$ |\n", "| \\lesseqgtr | $\\lesseqgtr$ |\n", "| \\lesseqqgtr | $\\lesseqqgtr$ |\n", "| \\lessgtr | $\\lessgtr$ |\n", "| \\lesssim | $\\lesssim$ |\n", "| \\ll | $\\ll$ |\n", "| \\lll | $\\lll$ |\n", "| \\lnapprox | $\\lnapprox$ |\n", "| \\lneqq | $\\lneqq$ |\n", "| \\lnsim | $\\lnsim$ |\n", "| \\ltimes | $\\ltimes$ |\n", "| \\mid | $\\mid$ |\n", "| \\models | $\\models$ |\n", "| \\mp | $\\mp$ |\n", "| \\nVDash | $\\nVDash$ |\n", "| \\nVdash | $\\nVdash$ |\n", "| \\napprox | $\\napprox$ |\n", "| \\ncong | $\\ncong$ |\n", "| \\ne | $\\ne$ |\n", "| \\neq | $\\neq$ |\n", "| \\neq | $\\neq$ |\n", "| \\nequiv | $\\nequiv$ |\n", "| \\ngeq | $\\ngeq$ |\n", "| \\ngtr | $\\ngtr$ |\n", "| \\ni | $\\ni$ |\n", "| \\nleq | $\\nleq$ |\n", "| \\nless | $\\nless$ |\n", "| \\nmid | $\\nmid$ |\n", "| \\notin | $\\notin$ |\n", "| \\nparallel | $\\nparallel$ |\n", "| \\nprec | $\\nprec$ |\n", "| \\nsim | $\\nsim$ |\n", "| \\nsubset | $\\nsubset$ |\n", "| \\nsubseteq | $\\nsubseteq$ |\n", "| \\nsucc | $\\nsucc$ |\n", "| \\nsupset | $\\nsupset$ |\n", "| \\nsupseteq | $\\nsupseteq$ |\n", "| \\ntriangleleft | $\\ntriangleleft$ |\n", "| \\ntrianglelefteq | $\\ntrianglelefteq$ |\n", "| \\ntriangleright | $\\ntriangleright$ |\n", "| \\ntrianglerighteq | $\\ntrianglerighteq$ |\n", "| \\nvDash | $\\nvDash$ |\n", "| \\nvdash | $\\nvdash$ |\n", "| \\odot | $\\odot$ |\n", "| \\ominus | $\\ominus$ |\n", "| \\oplus | $\\oplus$ |\n", "| \\oslash | $\\oslash$ |\n", "| \\otimes | $\\otimes$ |\n", "| \\parallel | $\\parallel$ |\n", "| \\perp | $\\perp$ |\n", "| \\pitchfork | $\\pitchfork$ |\n", "| \\pm | $\\pm$ |\n", "| \\prec | $\\prec$ |\n", "| \\precapprox | $\\precapprox$ |\n", "| \\preccurlyeq | $\\preccurlyeq$ |\n", "| \\preceq | $\\preceq$ |\n", "| \\precnapprox | $\\precnapprox$ |\n", "| \\precnsim | $\\precnsim$ |\n", "| \\precsim | $\\precsim$ |\n", "| \\propto | $\\propto$ |\n", "| \\rightthreetimes | $\\rightthreetimes$ |\n", "| \\risingdotseq | $\\risingdotseq$ |\n", "| \\rtimes | $\\rtimes$ |\n", "| \\sim | $\\sim$ |\n", "| \\simeq | $\\simeq$ |\n", "| \\slash | $\\slash$ |\n", "| \\smile | $\\smile$ |\n", "| \\sqcap | $\\sqcap$ |\n", "| \\sqcup | $\\sqcup$ |\n", "| \\sqsubset | $\\sqsubset$ |\n", "| \\sqsubset | $\\sqsubset$ |\n", "| \\sqsubseteq | $\\sqsubseteq$ |\n", "| \\sqsupset | $\\sqsupset$ |\n", "| \\sqsupset | $\\sqsupset$ |\n", "| \\sqsupseteq | $\\sqsupseteq$ |\n", "| \\star | $\\star$ |\n", "| \\subset | $\\subset$ |\n", "| \\subseteq | $\\subseteq$ |\n", "| \\subseteqq | $\\subseteqq$ |\n", "| \\subsetneq | $\\subsetneq$ |\n", "| \\subsetneqq | $\\subsetneqq$ |\n", "| \\succ | $\\succ$ |\n", "| \\succapprox | $\\succapprox$ |\n", "| \\succcurlyeq | $\\succcurlyeq$ |\n", "| \\succeq | $\\succeq$ |\n", "| \\succnapprox | $\\succnapprox$ |\n", "| \\succnsim | $\\succnsim$ |\n", "| \\succsim | $\\succsim$ |\n", "| \\supset | $\\supset$ |\n", "| \\supseteq | $\\supseteq$ |\n", "| \\supseteqq | $\\supseteqq$ |\n", "| \\supsetneq | $\\supsetneq$ |\n", "| \\supsetneqq | $\\supsetneqq$ |\n", "| \\therefore | $\\therefore$ |\n", "| \\times | $\\times$ |\n", "| \\top | $\\top$ |\n", "| \\triangleleft | $\\triangleleft$ |\n", "| \\trianglelefteq | $\\trianglelefteq$ |\n", "| \\triangleq | $\\triangleq$ |\n", "| \\triangleright | $\\triangleright$ |\n", "| \\trianglerighteq | $\\trianglerighteq$ |\n", "| \\uplus | $\\uplus$ |\n", "| \\vDash | $\\vDash$ |\n", "| \\varpropto | $\\varpropto$ |\n", "| \\vartriangleleft | $\\vartriangleleft$ |\n", "| \\vartriangleright | $\\vartriangleright$ |\n", "| \\vdash | $\\vdash$ |\n", "| \\vee | $\\vee$ |\n", "| \\veebar | $\\veebar$ |\n", "| \\wedge | $\\wedge$ |\n", "| \\wr | $\\wr$ |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Arrow symbols\n", "\n", " |Command|Result|\n", "|:-------|-------:|\n", "| \\Downarrow | $\\Downarrow$ |\n", "| \\Leftarrow | $\\Leftarrow$ |\n", "| \\Leftrightarrow | $\\Leftrightarrow$ |\n", "| \\Lleftarrow | $\\Lleftarrow$ |\n", "| \\Longleftarrow | $\\Longleftarrow$ |\n", "| \\Longleftrightarrow | $\\Longleftrightarrow$ |\n", "| \\Longrightarrow | $\\Longrightarrow$ |\n", "| \\Lsh | $\\Lsh$ |\n", "| \\Nearrow | $\\Nearrow$ |\n", "| \\Nwarrow | $\\Nwarrow$ |\n", "| \\Rightarrow | $\\Rightarrow$ |\n", "| \\Rrightarrow | $\\Rrightarrow$ |\n", "| \\Rsh | $\\Rsh$ |\n", "| \\Searrow | $\\Searrow$ |\n", "| \\Swarrow | $\\Swarrow$ |\n", "| \\Uparrow | $\\Uparrow$ |\n", "| \\Updownarrow | $\\Updownarrow$ |\n", "| \\circlearrowleft | $\\circlearrowleft$ |\n", "| \\circlearrowright | $\\circlearrowright$ |\n", "| \\curvearrowleft | $\\curvearrowleft$ |\n", "| \\curvearrowright | $\\curvearrowright$ |\n", "| \\dashleftarrow | $\\dashleftarrow$ |\n", "| \\dashrightarrow | $\\dashrightarrow$ |\n", "| \\downarrow | $\\downarrow$ |\n", "| \\downdownarrows | $\\downdownarrows$ |\n", "| \\downharpoonleft | $\\downharpoonleft$ |\n", "| \\downharpoonright | $\\downharpoonright$ |\n", "| \\hookleftarrow | $\\hookleftarrow$ |\n", "| \\hookrightarrow | $\\hookrightarrow$ |\n", "| \\leadsto | $\\leadsto$ |\n", "| \\leftarrow | $\\leftarrow$ |\n", "| \\leftarrowtail | $\\leftarrowtail$ |\n", "| \\leftharpoondown | $\\leftharpoondown$ |\n", "| \\leftharpoonup | $\\leftharpoonup$ |\n", "| \\leftleftarrows | $\\leftleftarrows$ |\n", "| \\leftrightarrow | $\\leftrightarrow$ |\n", "| \\leftrightarrows | $\\leftrightarrows$ |\n", "| \\leftrightharpoons | $\\leftrightharpoons$ |\n", "| \\leftrightsquigarrow | $\\leftrightsquigarrow$ |\n", "| \\leftsquigarrow | $\\leftsquigarrow$ |\n", "| \\longleftarrow | $\\longleftarrow$ |\n", "| \\longleftrightarrow | $\\longleftrightarrow$ |\n", "| \\longmapsto | $\\longmapsto$ |\n", "| \\longrightarrow | $\\longrightarrow$ |\n", "| \\looparrowleft | $\\looparrowleft$ |\n", "| \\looparrowright | $\\looparrowright$ |\n", "| \\mapsto | $\\mapsto$ |\n", "| \\multimap | $\\multimap$ |\n", "| \\nLeftarrow | $\\nLeftarrow$ |\n", "| \\nLeftrightarrow | $\\nLeftrightarrow$ |\n", "| \\nRightarrow | $\\nRightarrow$ |\n", "| \\nearrow | $\\nearrow$ |\n", "| \\nleftarrow | $\\nleftarrow$ |\n", "| \\nleftrightarrow | $\\nleftrightarrow$ |\n", "| \\nrightarrow | $\\nrightarrow$ |\n", "| \\nwarrow | $\\nwarrow$ |\n", "| \\rightarrow | $\\rightarrow$ |\n", "| \\rightarrowtail | $\\rightarrowtail$ |\n", "| \\rightharpoondown | $\\rightharpoondown$ |\n", "| \\rightharpoonup | $\\rightharpoonup$ |\n", "| \\rightleftarrows | $\\rightleftarrows$ |\n", "| \\rightleftarrows | $\\rightleftarrows$ |\n", "| \\rightleftharpoons | $\\rightleftharpoons$ |\n", "| \\rightleftharpoons | $\\rightleftharpoons$ |\n", "| \\rightrightarrows | $\\rightrightarrows$ |\n", "| \\rightrightarrows | $\\rightrightarrows$ |\n", "| \\rightsquigarrow | $\\rightsquigarrow$ |\n", "| \\searrow | $\\searrow$ |\n", "| \\swarrow | $\\swarrow$ |\n", "| \\to | $\\to$ |\n", "| \\twoheadleftarrow | $\\twoheadleftarrow$ |\n", "| \\twoheadrightarrow | $\\twoheadrightarrow$ |\n", "| \\uparrow | $\\uparrow$ |\n", "| \\updownarrow | $\\updownarrow$ |\n", "| \\updownarrow | $\\updownarrow$ |\n", "| \\upharpoonleft | $\\upharpoonleft$ |\n", "| \\upharpoonright | $\\upharpoonright$ |\n", "| \\upuparrows | $\\upuparrows$ |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Miscellaneous symbols\n", "\n", " |Command|Result|\n", "|:-------|-------:|\n", "| \\$ | $\\$$ |\n", "| \\AA | $\\AA$ |\n", "| \\Finv | $\\Finv$ |\n", "| \\Game | $\\Game$ |\n", "| \\Im | $\\Im$ |\n", "| \\P | $\\P$ |\n", "| \\Re | $\\Re$ |\n", "| \\S | $\\S$ |\n", "| \\angle | $\\angle$ |\n", "| \\backprime | $\\backprime$ |\n", "| \\bigstar | $\\bigstar$ |\n", "| \\blacksquare | $\\blacksquare$ |\n", "| \\blacktriangle | $\\blacktriangle$ |\n", "| \\blacktriangledown | $\\blacktriangledown$ |\n", "| \\cdots | $\\cdots$ |\n", "| \\checkmark | $\\checkmark$ |\n", "| \\circledR | $\\circledR$ |\n", "| \\circledS | $\\circledS$ |\n", "| \\clubsuit | $\\clubsuit$ |\n", "| \\complement | $\\complement$ |\n", "| \\copyright | $\\copyright$ |\n", "| \\ddots | $\\ddots$ |\n", "| \\diamondsuit | $\\diamondsuit$ |\n", "| \\ell | $\\ell$ |\n", "| \\emptyset | $\\emptyset$ |\n", "| \\eth | $\\eth$ |\n", "| \\exists | $\\exists$ |\n", "| \\flat | $\\flat$ |\n", "| \\forall | $\\forall$ |\n", "| \\hbar | $\\hbar$ |\n", "| \\heartsuit | $\\heartsuit$ |\n", "| \\hslash | $\\hslash$ |\n", "| \\iiint | $\\iiint$ |\n", "| \\iint | $\\iint$ |\n", "| \\iint | $\\iint$ |\n", "| \\imath | $\\imath$ |\n", "| \\infty | $\\infty$ |\n", "| \\jmath | $\\jmath$ |\n", "| \\ldots | $\\ldots$ |\n", "| \\measuredangle | $\\measuredangle$ |\n", "| \\natural | $\\natural$ |\n", "| \\neg | $\\neg$ |\n", "| \\nexists | $\\nexists$ |\n", "| \\oiiint | $\\oiiint$ |\n", "| \\partial | $\\partial$ |\n", "| \\prime | $\\prime$ |\n", "| \\sharp | $\\sharp$ |\n", "| \\spadesuit | $\\spadesuit$ |\n", "| \\sphericalangle | $\\sphericalangle$ |\n", "| \\ss | $\\ss$ |\n", "| \\triangledown | $\\triangledown$ |\n", "| \\varnothing | $\\varnothing$ |\n", "| \\vartriangle | $\\vartriangle$ |\n", "| \\vdots | $\\vdots$ |\n", "| \\wp | $\\wp$ |\n", "| \\yen | $\\yen$ |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example\n", "Here is an example illustrating many of these features in context." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy\n", "import vcs\n", "import cdms2\n", "import MV2\n", "\n", "x=vcs.init(bg=True,geometry=(400,400))\n", "a = cdms2.createAxis(numpy.arange(0.0, 2.0, 0.01))\n", "#a.id = \"time\"\n", "#a.units=\"second since 2017-09-25\"\n", "\n", "s = numpy.sin(2*numpy.pi*a[:])\n", "s = cdms2.createVariable(s,axes=[a,])\n", "s.title = r'$\\alpha_i > \\beta_i$'\n", "s.id = \"volts\"\n", "s.units=\"mV\"\n", "\n", "# Graphic method\n", "y = vcs.create1d()\n", "y.datawc_y1 = -1.1\n", "y.datawc_y2 = 1.1\n", "y.datawc_x1 = -0.1\n", "y.datawc_x2 = 2.1\n", "y.linecolor=\"blue\"\n", "y.markercolor=[0,0,0,0]\n", "\n", "# template\n", "t = vcs.createtemplate()\n", "to = vcs.createtextorientation()\n", "to.height = 20\n", "t.title.textorientation = to\n", "\n", "x.plot(s,y,t)\n", "text = vcs.createtext()\n", "text.x = [1.2]\n", "text.y = [-.5]\n", "text.string = [r'$\\sum_{i=0}^\\infty x_i$']\n", "text.height = 55\n", "text.color=\"dark grey\"\n", "text.halign = \"center\"\n", "# match text viewport to data area\n", "text.viewport = [t.data.x1,t.data.x2,t.data.y1,t.data.y2]\n", "# match text worldcoordinate to data's one\n", "text.worldcoordinate = [y.datawc_x1,y.datawc_x2,y.datawc_y1,y.datawc_y2]\n", "x.plot(text)\n", "\n", "text2 = vcs.createtext()\n", "# match text viewport to data area\n", "text2.viewport = [t.data.x1,t.data.x2,t.data.y1,t.data.y2]\n", "# match text worldcoordinate to data's one\n", "text2.worldcoordinate = [y.datawc_x1,y.datawc_x2,y.datawc_y1,y.datawc_y2]\n", "text2.x = [.75]\n", "text2.y = [.75]\n", "text2.halign=\"center\"\n", "text2.height = 45\n", "text2.color= \"red\"\n", "text2.string = [r'$\\mathcal{A}\\mathrm{sin}(2 \\omega t)$']\n", "x.plot(text2)" ] } ], "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.7.3" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": false, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }