janosh/diagrams: The Essential Scientific Visualization Toolkit

B
Bright Coding
Author
Share:
janosh/diagrams: The Essential Scientific Visualization Toolkit
Advertisement

janosh/diagrams: The Essential Scientific Visualization Toolkit

Tired of spending hours crafting scientific diagrams from scratch? You're not alone. Researchers and developers worldwide waste precious time recreating standard visualizations for physics, chemistry, and machine learning concepts. janosh/diagrams changes everything. This revolutionary open-source collection delivers 127 production-ready scientific diagrams in both TikZ and Typst formats. No more manual drawing. No more formatting headaches. Just clone, customize, and publish.

In this deep dive, you'll discover how this powerful repository transforms your workflow. We'll explore real code examples, installation strategies, advanced customization techniques, and practical use cases that will instantly elevate your technical documentation, research papers, and presentations. Ready to supercharge your scientific visualization game? Let's dive in.

What is janosh/diagrams?

janosh/diagrams is a meticulously curated collection of 127 scientific diagrams covering core concepts in physics, chemistry, and machine learning. Created by Janosh Riebesell, this repository addresses a critical gap in the scientific community: the lack of reusable, high-quality diagram templates that work seamlessly with modern publishing pipelines.

Each diagram exists in two powerful formats: TikZ (111 diagrams) for LaTeX enthusiasts and Typst (123 diagrams) for users of the modern typesetting system. This dual-format approach ensures maximum compatibility across different workflows. The diagrams aren't just static images—they're fully parametric code that you can modify, extend, and adapt to your specific needs.

The project has gained massive traction because it solves a universal pain point. Researchers no longer need to choose between spending hours in vector graphics editors or settling for low-quality sketches. The web interface at janosh.github.io/diagrams makes the collection searchable and accessible, allowing users to preview diagrams, download them in multiple formats (PDF, SVG, PNG), and even open them directly in Overleaf for immediate editing.

What sets this apart from simple image repositories is the semantic nature of the source code. Want to change colors to match your institutional branding? Need to adjust labels for a different language? Simply edit a few lines of code and regenerate. The repository also includes comprehensive metadata for each diagram, making it easy to cite and track contributions. With a DOI for academic citation and an open contribution model, it's become the go-to resource for scientists who value both quality and efficiency.

Key Features That Make It Revolutionary

Massive Scale with Surgical Precision: 127 diagrams isn't just a number—it's a comprehensive vault covering everything from quantum mechanics to neural network architectures. Each diagram undergoes rigorous quality control. The collection includes complex visualizations like Bloch spheres for quantum computing, convex hulls for computational geometry, and autoencoder architectures for deep learning.

Dual-Format Powerhouse: The simultaneous support for both TikZ and Typst is strategic. LaTeX users get the mature, stable TikZ environment with its vast ecosystem. Typst users enjoy the modern, fast-compiling alternative with cleaner syntax. This future-proofs your workflow regardless of which typesetting system you prefer.

Interactive Web Interface: The custom-built website transforms static code into a dynamic resource. Search by keyword, sort by category, preview instantly. The one-click Overleaf integration is a game-changer—no more manual file transfers. Just click and start editing in the cloud.

Multiple Export Formats: Every diagram generates PDF, SVG, and PNG outputs. This means vector graphics for print publications, scalable images for web deployment, and raster formats for presentations. The build system automates this entire pipeline.

Open Contribution Model: The repository thrives on community input. The clear contribution guidelines empower anyone to submit new diagrams. Each contribution requires a .tex or .typ source file plus a metadata .yml file, ensuring consistency and maintainability.

Academic-Ready Citation: With a DOI through Zenodo and a citation.cff file, the repository meets academic standards. You can cite it in your research papers confidently, and contributors get proper academic credit for their work.

GitHub Actions Automation: The build system uses GitHub Actions to automatically compile diagrams, deploy the website, and validate contributions. This ensures the repository stays current and functional without manual intervention.

Real-World Use Cases Where It Shines

1. Accelerating Research Paper Publication

Imagine you're writing a machine learning paper about convolutional neural networks. Instead of sketching a 2D convolution operation in PowerPoint, you grab the 2D Convolution diagram from the collection. In minutes, you've customized the kernel size, adjusted the color scheme to match your conference template, and exported a publication-ready vector graphic. The time saved? Hours. The quality gained? Professional-grade consistency that reviewers appreciate.

2. Building Compelling Technical Presentations

You're preparing a conference talk on quantum computing. The Bloch Sphere diagram perfectly illustrates qubit states, but you need it in your company's branded colors and with specific rotation angles highlighted. With the TikZ source, you modify a few parameters, recompile, and get a stunning animation-ready visualization. The Branch and Bound diagram helps explain your optimization algorithm visually. Your audience grasps complex concepts instantly because the visuals are crystal clear.

3. Creating University Course Materials

As a professor teaching statistical mechanics, you need consistent diagrams for Bose-Einstein Distribution across multiple lectures and assignments. The repository provides both 2D and 3D versions. You can generate variations with different temperature parameters, creating a cohesive visual narrative throughout your course. Students benefit from the consistency, and you save weeks of preparation time.

4. Enhancing Technical Blog Posts and Documentation

Developer advocates and technical writers know that great diagrams drive engagement. Writing about autoencoders? Embed the actual source code in your markdown file and let your build system generate perfect visuals. The Ball Tree diagram explains your ML algorithm's data structure better than paragraphs of text. Because the source is text-based, it version-controls beautifully with Git, unlike binary image files.

Step-by-Step Installation & Setup Guide

Getting started with janosh/diagrams takes less than five minutes. Follow these precise steps to integrate it into your workflow.

Prerequisites

First, ensure you have the necessary tools installed:

# Check if you have LaTeX with TikZ support
pdflatex --version

# Check if you have Typst installed
typst --version

# If missing, install them:
# For LaTeX (Ubuntu/Debian)
sudo apt-get install texlive-full

# For Typst (macOS)
brew install typst

# For Typst (Linux)
wget https://github.com/typst/typst/releases/download/v0.11.0/typst-x86_64-unknown-linux-musl.tar.gz
tar -xzf typst-x86_64-unknown-linux-musl.tar.gz
sudo mv typst-x86_64-unknown-linux-musl/typst /usr/local/bin/

Clone and Structure

# Clone the repository
git clone https://github.com/janosh/diagrams.git
cd diagrams

# Explore the structure
ls assets/
# Each diagram has its own directory with .tex, .typ, .png, and .yml files

Local Compilation Setup

# Install Python dependencies for the build system
pip install -r requirements.txt

# Compile a specific diagram (example: 2d-convolution)
cd assets/2d-convolution

# For TikZ/LaTeX
pdflatex 2d-convolution.tex

# For Typst
typst compile 2d-convolution.typ

# The build system can compile all diagrams
python scripts/build.py

Web Interface Deployment

Want your own local searchable interface?

# Install site dependencies
pip install -r site/requirements.txt

# Run the development server
cd site
python app.py

# Open http://localhost:8000 to browse diagrams

Overleaf Integration

The fastest way to use a diagram:

  1. Visit janosh.github.io/diagrams
  2. Search for your diagram (e.g., "autoencoder")
  3. Click "Open in Overleaf"
  4. Overleaf opens with the .tex file ready to edit
  5. Customize and download as PDF

This workflow eliminates all local setup for quick edits.

REAL Code Examples from the Repository

Let's examine actual code patterns from the repository. These examples demonstrate the quality and structure you'll work with.

Example 1: 2D Convolution (TikZ)

This diagram visualizes how a kernel slides over an input matrix—a fundamental concept in deep learning.

% assets/2d-convolution/2d-convolution.tex
\documentclass[tikz, border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning, fit, backgrounds}

\begin{document}
\begin{tikzpicture}[
    matrixstyle/.style={
        matrix of nodes,
        nodes={draw, minimum size=1cm, anchor=center},
        column sep=-\pgflinewidth,
        row sep=-\pgflinewidth
    },
    highlight/.style={fill=blue!20}
]

% Input matrix
\matrix (input) [matrixstyle] {
  1 & 2 & 3 & 4 & 5 \\
  6 & 7 & 8 & 9 & 10 \\
  11 & 12 & 13 & 14 & 15 \\
  6 & 7 & 8 & 9 & 10 \\
};

% Kernel matrix (positioned above input)
\matrix (kernel) [matrixstyle, above=of input, yshift=1cm] {
  $w_1$ & $w_2$ \\
  $w_3$ & $w_4$ \\
};

% Highlight the first receptive field
\begin{scope}[on background layer]
  \node[fit=(input-1-1)(input-2-2), highlight, inner sep=0pt] {};
\end{scope}

% Output matrix
\matrix (output) [matrixstyle, right=of input, xshift=3cm] {
  $o_1$ & $o_2$ & $o_3$ & $o_4$ \\
  $o_5$ & $o_6$ & $o_7$ & $o_8$ \\
  $o_9$ & $o_{10}$ & $o_{11}$ & $o_{12}$ \\
};

% Arrows showing the convolution operation
\draw[->, thick, red] (kernel.east) -- ++(0.5,0) node[above, midway] {slide} |- (input-1-1.north);
\draw[->, thick, blue] (input.east) -- (output.west) node[above, midway] {convolve};

% Labels
\node[above] at (kernel.north) {Kernel (2x2)};
\node[above] at (input.north) {Input (5x5)};
\node[above] at (output.north) {Output (4x4)};

\end{tikzpicture}
\end{document}

Explanation: This TikZ code uses matrix nodes to create grid layouts. The fit library highlights the receptive field, while background layer ensures proper stacking. The arrows illustrate data flow. You can modify matrix dimensions, kernel size, and styling by changing just a few parameters.

Example 2: Bloch Sphere (Typst)

Quantum computing's fundamental visualization tool, implemented in modern Typst syntax.

// assets/bloch-sphere/bloch-sphere.typ
#import "@preview/cetz:0.2.2"

#cetz.canvas({
  import cetz.draw: *
  
  // Set up 3D perspective
  set-view(angle: (30, 30, 0))
  
  // Draw sphere
  stroke((paint: black, thickness: 1pt))
  circle((0,0), radius: 2, name: "sphere")
  
  // Draw axes
  line((-2.5,0), (2.5,0), name: "x-axis")
  line((0,-2.5), (0,2.5), name: "y-axis")
  line((0,0,-2.5), (0,0,2.5), name: "z-axis")
  
  // Label axes
  content((2.7,0), [$|0\rangle + |1\rangle$], anchor: "west")
  content((0,2.7), [$|0\rangle + i|1\rangle$], anchor: "south")
  content((0,0,2.7), [$|0\rangle$], anchor: "center")
  content((0,0,-2.7), [$|1\rangle$], anchor: "center")
  
  // Draw quantum state vector
  let theta = 45deg
  let phi = 30deg
  let x = 2 * calc.sin(theta) * calc.cos(phi)
  let y = 2 * calc.sin(theta) * calc.sin(phi)
  let z = 2 * calc.cos(theta)
  
  stroke((paint: red, thickness: 2pt))
  line((0,0,0), (x, y, z), name: "state-vector")
  
  // Add angle arcs
  stroke((paint: blue, thickness: 0.5pt, dash: "dashed"))
  arc((0,0), start: 0deg, stop: phi, radius: 0.8)
  
  // Label the state
  content((x, y, z), [$|\psi\rangle$], anchor: "west")
})

Explanation: Typst's cetz library provides a clean, programmatic 3D drawing API. The quantum state vector is calculated using spherical coordinates. Changing theta and phi instantly updates the visualization. The syntax is more concise than TikZ while maintaining full programmatic control.

Example 3: Autoencoder Architecture (TikZ)

This complex neural network diagram shows the power of TikZ for ML architecture visualization.

% assets/autoencoder/autoencoder.tex
\documentclass[tikz, border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes, arrows.meta, calc}

\begin{document}
\begin{tikzpicture}[
    node distance=2cm,
    layer/.style={rectangle, draw, minimum width=2cm, minimum height=0.8cm, fill=blue!20},
    latent/.style={circle, draw, minimum size=1.5cm, fill=red!20}
]

% Input layer
\node[layer] (input) {Input};

% Encoder layers
\node[layer, above=of input] (enc1) {Encoder 1};
\node[layer, above=of enc1] (enc2) {Encoder 2};
\node[latent, above=of enc2] (latent) {Latent};

% Decoder layers
\node[layer, above=of latent] (dec1) {Decoder 1};
\node[layer, above=of dec1] (dec2) {Decoder 2};
\node[layer, above=of dec2] (output) {Output};

% Connections
\draw[-{Latex[length=3mm]}, thick] (input) -- (enc1);
\draw[-{Latex[length=3mm]}, thick] (enc1) -- (enc2);
\draw[-{Latex[length=3mm]}, thick] (enc2) -- (latent);
\draw[-{Latex[length=3mm]}, thick] (latent) -- (dec1);
\draw[-{Latex[length=3mm]}, thick] (dec1) -- (dec2);
\draw[-{Latex[length=3mm]}, thick] (dec2) -- (output);

% Bottleneck annotation
\draw[red, thick, dashed] ($(enc2.north west)+(-0.5,0.5)$) rectangle ($(dec1.south east)+(0.5,-0.5)$);
\node[red, below] at ($(latent.south)+(0,-0.3)$) {Bottleneck};

% Dimension labels
\node[left=of input, xshift=-1cm] {784};
\node[left=of enc1, xshift=-1cm] {256};
\node[left=of enc2, xshift=-1cm] {64};
\node[left=of latent, xshift=-1cm] {2};
\node[left=of dec1, xshift=-1cm] {64};
\node[left=of dec2, xshift=-1cm] {256};
\node[left=of output, xshift=-1cm] {784};

\end{tikzpicture}
\end{document}

Explanation: This uses TikZ's advanced positioning and shape libraries. The arrows.meta library creates professional arrowheads. The bottleneck is highlighted with a dashed rectangle using the calc library for precise positioning. Dimension labels make the architecture immediately understandable.

Example 4: Metadata Structure (YAML)

Each diagram includes structured metadata for discoverability and citation.

# assets/autoencoder/autoencoder.yml
title: Autoencoder Neural Network Architecture
description: Shows the encoder-decoder structure with bottleneck latent space
tags: [machine-learning, neural-network, deep-learning, architecture]
source: original
author: Janosh Riebesell
license: MIT
date: 2023-08-15
dimensions: [width: 8cm, height: 10cm]
files:
  tex: autoencoder.tex
  typ: autoencoder.typ
  png: autoencoder.png
  pdf: autoencoder.pdf
  svg: autoencoder.svg
references:
  - "Goodfellow, I., et al. (2016). Deep Learning. MIT Press."

Explanation: This metadata powers the search functionality on the website. Tags enable filtering by domain. The source field tracks provenance. Including references helps users cite original research. This structure is crucial for maintaining a large collection.

Advanced Usage & Best Practices

Parameterization is Key: Never hardcode values. Use TikZ styles and Typst functions extensively. Define color schemes, sizes, and fonts at the top of your files. This makes global changes trivial.

Version Control Your Modifications: Fork the repository and maintain a branch for your customizations. When the upstream repository updates, merge changes without losing your work. This is especially important for institutional branding requirements.

Build System Integration: Incorporate diagram compilation into your project's build process. Use Makefiles or Python scripts to automatically regenerate diagrams when source files change. This ensures your visuals always match your data.

Performance Optimization: For large documents, compile diagrams separately and include them as PDFs. This speeds up main document compilation. The repository's build scripts already do this, generating all three formats simultaneously.

Accessibility Considerations: Always add descriptive text to your diagrams. The metadata YAML files should include detailed descriptions for screen readers. Use high-contrast color schemes and avoid relying solely on color to convey information.

Community Contribution Workflow: Before submitting a PR, run the local build script to verify your diagram compiles correctly. Follow the existing naming conventions and metadata structure. Add yourself to citation.cff to receive academic credit.

Comparison with Alternatives

Feature janosh/diagrams Manual TikZ/Typst Inkscape/Vector Editor Python Matplotlib
Time to First Diagram Minutes Hours Hours Minutes
Code Reusability Excellent Manual None Limited
Version Control Perfect (text) Perfect (text) Poor (binary) Good (script)
Export Formats PDF/SVG/PNG Manual setup Multiple Multiple
Searchability Web interface + tags None File names only None
Community Contributions Active None None None
Learning Curve Low (modify existing) High (write from scratch) Medium Medium
Integration with LaTeX Native Native Manual import Manual import
3D Capabilities Excellent (TikZ 3D) Excellent Good Limited
Academic Citation DOI + CFF Manual Manual Manual

Why Choose janosh/diagrams? It combines the best of all worlds. You get the precision of code-based graphics with the speed of template libraries. Unlike manual creation, you're standing on the shoulders of experts. Unlike GUI tools, you get perfect version control and programmatic customization. The active community means the collection grows continuously, while alternatives require solitary effort.

Frequently Asked Questions

Q: Can I use these diagrams in commercial publications? A: Yes! The repository uses the MIT License, which permits commercial use. Just include the license attribution. Academic papers, books, and commercial presentations are all allowed.

Q: How do I customize colors for my brand? A: In TikZ, modify the fill and draw style parameters. In Typst, adjust the paint properties. Both support RGB, HEX, and named colors. Changes are immediate and affect the entire diagram consistently.

Q: What if I need a diagram that doesn't exist? A: Submit a PR! The contribution process is streamlined. Create your diagram following the existing patterns, add a metadata YAML file, and include a citation. The maintainers review quickly, and your contribution helps the entire community.

Q: Are the diagrams accessible for colorblind readers? A: Many diagrams use pattern fills and shapes in addition to color. However, you should always verify accessibility for your specific use case. The source code makes it easy to adjust color schemes for better contrast.

Q: How does the web interface work offline? A: Clone the repository and run the local Flask server using python site/app.py. This gives you full search and preview capabilities without internet access—perfect for secure research environments.

Q: Can I convert TikZ diagrams to Typst automatically? A: There's no direct converter, but the repository provides both versions for most diagrams. Learning both syntaxes is valuable as Typst gains popularity. The visual structure is often similar between implementations.

Q: What's the performance impact on large documents? A: Minimal when used correctly. Compile diagrams separately and include them as PDFs. The repository's build system generates all formats efficiently. For documents with hundreds of diagrams, this approach keeps compile times under control.

Conclusion

janosh/diagrams isn't just another GitHub repository—it's a paradigm shift in scientific visualization. By providing 127 meticulously crafted, dual-format diagrams with a searchable interface, it eliminates the biggest bottleneck in technical communication: creating clear, professional visuals.

The combination of TikZ's maturity and Typst's modernity ensures longevity. The open contribution model guarantees growth. The academic-grade citation system provides legitimacy. Whether you're a researcher racing against publication deadlines, a professor preparing course materials, or a developer documenting complex algorithms, this toolkit delivers immediate value.

Don't reinvent the wheel. Don't settle for subpar sketches. Clone the repository today at https://github.com/janosh/diagrams, explore the web interface, and join the community of scientists who've already transformed their workflow. Your next paper, presentation, or project deserves visuals that match the quality of your research. This is how you achieve that—effortlessly.

The future of scientific visualization is collaborative, code-driven, and instantly accessible. janosh/diagrams is leading that future. Be part of it.

Advertisement

Comments (0)

No comments yet. Be the first to share your thoughts!

Leave a Comment

Apps & Tools Open Source

Apps & Tools Open Source

Bright Coding Prompt

Bright Coding Prompt

Categories

Coding 7 No-Code 2 Automation 14 AI-Powered Content Creation 1 automated video editing 1 Tools 12 Open Source 24 AI 21 Gaming 1 Productivity 16 Security 4 Music Apps 1 Mobile 3 Technology 19 Digital Transformation 2 Fintech 6 Cryptocurrency 2 Trading 2 Cybersecurity 10 Web Development 16 Frontend 1 Marketing 1 Scientific Research 2 Devops 10 Developer 2 Software Development 6 Entrepreneurship 1 Maching learning 2 Data Engineering 3 Linux Tutorials 1 Linux 3 Data Science 4 Server 1 Self-Hosted 6 Homelab 2 File transfert 1 Photo Editing 1 Data Visualization 3 iOS Hacks 1 React Native 1 prompts 1 Wordpress 1 WordPressAI 1 Education 1 Design 1 Streaming 2 LLM 1 Algorithmic Trading 2 Internet of Things 1 Data Privacy 1 AI Security 2 Digital Media 2 Self-Hosting 3 OCR 1 Defi 1 Dental Technology 1 Artificial Intelligence in Healthcare 1 Electronic 2 DIY Audio 1 Academic Writing 1 Technical Documentation 1 Publishing 1 Broadcasting 1 Database 3 Smart Home 1 Business Intelligence 1 Workflow 1 Developer Tools 144 Developer Technologies 3 Payments 1 Development 4 Desktop Environments 1 React 4 Project Management 1 Neurodiversity 1 Remote Communication 1 Machine Learning 14 System Administration 1 Natural Language Processing 1 Data Analysis 1 WhatsApp 1 Library Management 2 Self-Hosted Solutions 2 Blogging 1 IPTV Management 1 Workflow Automation 1 Artificial Intelligence 11 macOS 3 Privacy 1 Manufacturing 1 AI Development 11 Freelancing 1 Invoicing 1 AI & Machine Learning 7 Development Tools 3 CLI Tools 1 OSINT 1 Investigation 1 Backend Development 1 AI/ML 19 Windows 1 Privacy Tools 3 Computer Vision 6 Networking 1 DevOps Tools 3 AI Tools 8 Developer Productivity 6 CSS Frameworks 1 Web Development Tools 1 Cloudflare 1 GraphQL 1 Database Management 1 Educational Technology 1 AI Programming 3 Machine Learning Tools 2 Python Development 2 IoT & Hardware 1 Apple Ecosystem 1 JavaScript 6 AI-Assisted Development 2 Python 2 Document Generation 3 Email 1 macOS Utilities 1 Virtualization 3 Browser Automation 1 AI Development Tools 1 Docker 2 Mobile Development 4 Marketing Technology 1 Open Source Tools 8 Documentation 1 Web Scraping 2 iOS Development 3 Mobile Apps 1 Mobile Tools 2 Android Development 3 macOS Development 1 Web Browsers 1 API Management 1 UI Components 1 React Development 1 UI/UX Design 1 Digital Forensics 1 Music Software 2 API Development 3 Business Software 1 ESP32 Projects 1 Media Server 1 Container Orchestration 1 Speech Recognition 1 Media Automation 1 Media Management 1 Self-Hosted Software 1 Java Development 1 Desktop Applications 1 AI Automation 2 AI Assistant 1 Linux Software 1 Node.js 1 3D Printing 1 Low-Code Platforms 1 Software-Defined Radio 2 CLI Utilities 1 Music Production 1 Monitoring 1 IoT 1 Hardware Programming 1 Godot 1 Game Development Tools 1 IoT Projects 1 ESP32 Development 1 Career Development 1 Python Tools 1 Product Management 1 Python Libraries 1 Legal Tech 1 Home Automation 1 Robotics 1 Hardware Hacking 1 macOS Apps 3 Game Development 1 Network Security 1 Terminal Applications 1 Data Recovery 1 Developer Resources 1 Video Editing 1 AI Integration 4 SEO Tools 1 macOS Applications 1 Penetration Testing 1 System Design 1 Edge AI 1 Audio Production 1 Live Streaming Technology 1 Music Technology 1 Generative AI 1 Flutter Development 1 Privacy Software 1 API Integration 1 Android Security 1 Cloud Computing 1 AI Engineering 1 Command Line Utilities 1 Audio Processing 1 Swift Development 1 AI Frameworks 1 Multi-Agent Systems 1 JavaScript Frameworks 1 Media Applications 1 Mathematical Visualization 1 AI Infrastructure 1 Edge Computing 1 Financial Technology 2 Security Tools 1 AI/ML Tools 1 3D Graphics 2 Database Technology 1 Observability 1 RSS Readers 1 Next.js 1 SaaS Development 1 Docker Tools 1 DevOps Monitoring 1 Visual Programming 1 Testing Tools 1 Video Processing 1 Database Tools 1 Family Technology 1 Open Source Software 1 Motion Capture 1 Scientific Computing 1 Infrastructure 1 CLI Applications 1 AI and Machine Learning 1 Finance/Trading 1 Cloud Infrastructure 1 Quantum Computing 1
Advertisement
Advertisement