Repository navigation
Write variables as math text in examples and README - #12
Merged
Merged
Conversation
Labels and legends in the examples and README code write variables and formulas as math text ($x$, $y$, $\sin(x)$, $X$ measure), so variables are set in Arial Italic and function names upright, as in an equation. The Arial check in the examples also requires the italic face. README and AGENTS.md state the convention, and a test checks that the style resolves math variables to an italic face and function names to an upright one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Variables and formulas in figure text are written as math text, so they are set like an equation: variables in Arial Italic, function names, numbers and parentheses upright (the style's
mathtext.it/mathtext.rm). Math text uses Matplotlib's built-in TeX parser and needs no LaTeX installation.examples/styles_demo.py:"x","y","sin(x)","cos(x)","X measure","Y measure"become"$x$","$y$",r"$\sin(x)$",r"$\cos(x)$","$X$ measure","$Y$ measure"(also in the Matplotlib-defaults comparison, so the two differ only in style).add_custom_fontsexample registers Arial Italic.examples/_common.py: the Arial check also requires the italic face, which math variables use.default_style,graphpadprism_style,graphpadprism_errorbar(PNG, SVG, PDF). The Prism PDFs embedArialMTandArial-ItalicMT, both TrueType.Test plan
test_math_variables_are_italic_and_functions_upright: with the style,mathtext.itresolves to an Italic/Oblique face andmathtext.rmto an upright one.pre-commit run --all-filespytest(300 passed), also locally with Matplotlib 3.8.0 / NumPy 1.26.4.