# red-data-tools/gr-plot architecture

> Architecture diagram of the GitHub repository red-data-tools/gr-plot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/red-data-tools/gr-plot
- Repository: https://github.com/red-data-tools/gr-plot

## Overview

GR::Plot is a Ruby, MATLAB-style plotting API built on GR.rb. A caller selects a plot operation and supplies data/options; plot methods normalize or format inputs and dispatch drawing through the central plot renderer to GR. The documented surface includes 2D and 3D plots, statistical and contour plots, and histogram support. GR3 is an optional integration for 3D rendering. The excerpts show only parts of the main implementation, so uncertain internal links are omitted.

Main entry points: [`lib/gr/plot.rb`](https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb) (Plot renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Plot API"]
  node_plot_api["Plot methods<br/>[plot.rb]"]
  node_formatting["Data formatting<br/>[plot.rb]"]
  node_histogram["Histogram bins<br/>[histogram.rb]"]
end

subgraph group_render["Plot rendering"]
  node_renderer["Plot renderer<br/>[plot.rb]"]
  node_plot_types["Plot types<br/>[plot.rb]"]
  node_layout["Axes and layout<br/>[plot.rb]"]
  node_legend["Legend drawing<br/>[plot.rb]"]
end

subgraph group_integration["Rendering integrations"]
  node_gr["GR graphics"]
  node_gr3["GR3 graphics"]
end

node_caller(("Ruby caller"))

node_caller -->|"calls"| node_plot_api
node_plot_api -->|"formats inputs"| node_formatting
node_plot_api -->|"dispatches plots"| node_renderer
node_renderer -->|"selects kind"| node_plot_types
node_renderer -->|"configures layout"| node_layout
node_renderer -->|"draws legend"| node_legend
node_renderer -->|"draws with"| node_gr
node_renderer -.->|"uses for 3D"| node_gr3

click node_plot_api "https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb"
click node_formatting "https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb"
click node_histogram "https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot/histogram.rb"
click node_renderer "https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb"
click node_plot_types "https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb"
click node_layout "https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb"
click node_legend "https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_plot_api,node_formatting,node_histogram toneBlue
class node_renderer,node_plot_types,node_layout,node_legend toneAmber
class node_gr,node_gr3 toneMint
class node_caller toneIndigo
```

## Components

### Plot API

- [Plot methods](https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb): `lib/gr/plot.rb`
- [Data formatting](https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb): `lib/gr/plot.rb`
- [Histogram bins](https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot/histogram.rb): `lib/gr/plot/histogram.rb`

### Plot rendering

- [Plot renderer](https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb): `lib/gr/plot.rb`
- [Plot types](https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb): `lib/gr/plot.rb`
- [Axes and layout](https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb): `lib/gr/plot.rb`
- [Legend drawing](https://github.com/red-data-tools/gr-plot/blob/main/lib/gr/plot.rb): `lib/gr/plot.rb`

### Rendering integrations

- **GR graphics**
- **GR3 graphics**

### Other components

- **Ruby caller**

## Connections

- Ruby caller → Plot methods: calls
- Plot methods → Data formatting: formats inputs
- Plot methods → Plot renderer: dispatches plots
- Plot renderer → Plot types: selects kind
- Plot renderer → Axes and layout: configures layout
- Plot renderer → Legend drawing: draws legend
- Plot renderer → GR graphics: draws with
- Plot renderer → GR3 graphics: uses for 3D
