--- name: desmos-graphing description: Create interactive Desmos graphs in Obsidian using desmos-graph code blocks. Use when visualizing functions, parametric curves, inequalities, or mathematical relationships with customizable styling and settings. --- # Desmos Graphing in Obsidian ## ⚠️ CRITICAL: Dual Parser System The plugin uses **different parsers** for different parts: | Location | Parser | pi | sqrt | Example | |----------|--------|-----|------|---------| | Settings | mathjs | `pi` | - | `left=-2*pi+0.5` | | Equations | Desmos (LaTeX) | `\pi` | `\sqrt{x}` | `y=\sqrt{x}+\pi` | | Points | Desmos (LaTeX) | `\pi` | `\sqrt{x}` | `(\pi/2, 1)` | | **Restrictions** | plain math | numeric | `x^0.5` | `x>-1.5708` | ```markdown ✅ CORRECT left=-0.5; right=2*pi+0.5 --- y=\sqrt{x}|blue y=x/\sqrt{3}|green|0<=x<=3^0.5 (\pi/2, 0)|label:cos(90°)=0 ❌ WRONG (will error) left=-2*\pi # Error: "Syntax error in part '\pi'" y=\sin(x+pi/4) # Error: "Too many variables" (p*i) (pi/2, 0) # Error: "Too many variables" ← Points need LaTeX! y=x/sqrt(3)|0<=x<=sqrt(3) # Error: "Too many variables" (s*q*r*t) ``` **Key rule**: `\sqrt{x}` in equations, `x^0.5` in restrictions! ## Code Block Format ````markdown ```desmos-graph [settings] --- [equations] ``` ```` - Settings (optional) above `---`, equations below - Each equation on its own line - Use `|` to add styling/restrictions to equations ## Quick Start ### Basic Function ````markdown ```desmos-graph y=x^2 y=\sin(x)|blue ``` ```` ### With Settings ````markdown ```desmos-graph left=-2*pi; right=2*pi bottom=-2; top=2 --- y=\sin(x)|red y=\cos(x)|blue|dashed ``` ```` ### Points and Labels ````markdown ```desmos-graph (0, 0)|label:Origin (3, 4)|red|label:Point A (\pi/2, 1)|blue|label:π/2 # Use \pi in coordinates! y=x|dashed ``` ```` ⚠️ Points use LaTeX: `(\pi/2, 0)` not `(pi/2, 0)` ## Essential Settings | Setting | Default | Description | |---------|---------|-------------| | `width` | 600 | Graph width in pixels | | `height` | 400 | Graph height in pixels | | `left` | -10 | Left boundary | | `right` | 10 | Right boundary | | `bottom` | -7 | Bottom boundary | | `top` | 7 | Top boundary | | `grid` | true | Show grid lines | | `degreeMode` | radians | `radians` or `degrees` | ### Additional Settings | Setting | Default | Description | |---------|---------|-------------| | `hideAxisNumbers` | false | Hide axis number labels | | `xAxisLabel` | - | Custom x-axis label | | `yAxisLabel` | - | Custom y-axis label | | `xAxisLogarithmic` | false | Logarithmic x-axis scale | | `yAxisLogarithmic` | false | Logarithmic y-axis scale | | `defaultColor` | - | Default color for all equations | Settings use `=` for values, separated by `;` or newlines. Bounds accept math expressions: `left=-2*pi` ## Equation Styling Use `|` (pipe) to add styling after an equation: ``` equation|color|style|restrictions|label ``` Segment order is flexible - the parser auto-detects each segment type. ⚠️ **CRITICAL: `|` is RESERVED as delimiter!** The pipe character cannot appear in equations or labels: ``` (1, 0)|label:|v|=5 # ❌ Error: label parsed as empty (1, 0)|label:∥v∥=5 # ✅ Use Unicode ∥ (U+2225) y=|x| # ❌ Error: pipes split the equation y=abs(x) # ✅ Use abs() function ``` ### Colors **Supported names:** `red`, `green`, `blue`, `yellow`, `orange`, `purple`, `cyan`, `magenta`, `black`, `white` **Hex codes:** `#rrggbb` or `#rgb` (e.g., `#ff6600`, `#f60`) ⚠️ **`gray`/`grey` are NOT supported!** Use hex instead: - Light gray: `#c0c0c0` - Medium gray: `#808080` - Dark gray: `#404040` ``` y=x|gray # ❌ Error: parsed as restriction y=x|#808080 # ✅ Correct ``` ### Line & Point Styles | Line | Point | Effect | |------|-------|--------| | `solid` | `point` | Default (solid/filled) | | `dashed` | `open` | Dashed/open circle | | `dotted` | `cross` | Dotted/X mark | ### Labels `(1, 2)|label` shows "(1, 2)", `(1, 2)|label:Point A` shows custom text ### Restrictions Limit where equations are drawn: ``` y=x^2|00|y>0 # Multiple restrictions y=2x|0<=x<=1 # <= and >= supported y=\tan(x)|x>-1.5708|x<1.5708 # Use numeric values (π/2≈1.5708) ``` **⚠️ CRITICAL: Use plain math, NOT LaTeX in restrictions!** | ✅ Correct | ❌ Wrong | Why | |-----------|---------|-----| | `x/2-1.5708` | `x>-pi/2` | `pi` → p*i, use numeric | | `0