plot rendering in markdown - chunhualiao/public-docs GitHub Wiki

GitHub Wiki's Markdown supports mathematical formula rendering but does not natively support generating plots from math formulas. Here's a detailed breakdown:


1. Math Formula Support

GitHub now natively renders LaTeX math expressions using $ for inline and $$ for block equations[5][9]. For example:

The quadratic formula: $$ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} $$

Renders as:
The quadratic formula: $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$

However, complex LaTeX environments (e.g., \begin{figure}, \tikz) are not supported[5][9].


2. Generating Plots from Math Formulas

For plots, you have two options:

Option 1: Convert Formulas to Images

  1. Generate the plot using tools like:
    • Python (matplotlib, sympy)
    • R (ggplot2)
    • Wolfram Alpha
    • Online LaTeX editors (e.g., Overleaf) with pgfplots or tikz.
  2. Upload the image to your repository or embed via URL.
  3. Embed in Markdown:
    ![Plot of \( y = x^2 \)](path/to/plot.png)
    

Option 2: Use GitHub’s Math Rendering Service

For simple 2D graphs, you can encode formulas into URLs using GitHub’s math renderer[1][2]:

<img src="https://render.githubusercontent.com/render/math?math=y%3Dx%5E2">

Renders as:

Limitations: This method only works for basic equations, not multi-axis plots or diagrams.


3. Mermaid Diagrams for Visualizations

While GitHub supports Mermaid diagrams for flowcharts and graphs[8], this is separate from mathematical plotting:

graph TD
  A[Math Formula] --> B{Plot}
  B --> C[Generate Image]
  B --> D[Use Mermaid]

Renders as a flowchart, not a mathematical plot.


Key Takeaways

Feature Support Example/Tool
LaTeX Math ✅ Native $E=mc^2$
Plots from Formulas ❌ Requires images matplotlib, Overleaf, Wolfram
Mermaid Diagrams ✅ Native Flowcharts, sequence diagrams

For advanced plots, use external tools to generate images and embed them in your wiki[1][5][8].

Citations: