Skip to content
Back to skills

2270 Bin B3e817d9

ASecurity

The bin transform aggregates quantitative or temporal data into discrete bins for histograms and heatmaps.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 31, 2026
developmentjavascriptgojava

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned May 31, 2026

npx -y skills add tools-only/X-Skills --skill 2270-bin_b3e817d9 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 2270 Bin B3e817d9?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 2270 Bin B3e817d9
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-2270-bin-b3e817d9/badge)](https://www.skillsdirectory.com/skills/tools-only-2270-bin-b3e817d9)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Bin Transform

The bin transform aggregates quantitative or temporal data into discrete bins for histograms and heatmaps.

## Constructors

```javascript
Plot.binX(outputs, options)   // Bin on x-axis
Plot.binY(outputs, options)   // Bin on y-axis
Plot.bin(outputs, options)    // Bin on both axes
```

## Basic Usage

```javascript
// Histogram
Plot.rectY(data, Plot.binX({y: "count"}, {x: "value"}))

// 2D Heatmap
Plot.rect(data, Plot.bin({fill: "count"}, {x: "weight", y: "height"}))
```

## Output Channels

The first argument specifies output channels:

```javascript
{y: "count"}           // Count items per bin
{y: "sum"}             // Sum values
{fill: "mean"}         // Mean for color
{r: "count"}           // Count for size
```

## Examples

### Basic Histogram
```javascript
Plot.rectY(data, Plot.binX({y: "count"}, {x: "value"})).plot()
```

### Stacked Histogram
```javascript
Plot.rectY(data, Plot.binX({y: "count"}, {
  x: "value",
  fill: "category"
})).plot()
```

### 2D Heatmap
```javascript
Plot.rect(data, Plot.bin({fill: "count"}, {
  x: "weight",
  y: "height"
})).plot({color: {scheme: "YlGnBu"}})
```

### Custom Thresholds
```javascript
Plot.rectY(data, Plot.binX({y: "count"}, {
  x: "value",
  thresholds: 20  // ~20 bins
})).plot()
```

### Specific Bin Edges
```javascript
Plot.rectY(data, Plot.binX({y: "count"}, {
  x: "value",
  thresholds: [0, 10, 20, 50, 100]
})).plot()
```

### Cumulative Distribution
```javascript
Plot.rectY(data, Plot.binX({y: "count"}, {
  x: "value",
  cumulative: 1
})).plot()
```

### Time-Based Bins
```javascript
Plot.rectY(data, Plot.binX({y: "count"}, {
  x: "date",
  thresholds: d3.utcMonth
})).plot()
```

## Reducers

| Reducer | Description |
|---------|-------------|
| `count` | Number of items |
| `sum` | Sum of values |
| `mean` | Average |
| `median` | Median value |
| `min`, `max` | Extremes |
| `mode` | Most common |
| `first`, `last` | First/last value |
| `deviation` | Standard deviation |
| `variance` | Variance |
| `proportion` | Proportion of total |
| `pXX` | Percentile (e.g., `p50`) |

## Options

| Option | Default | Description |
|--------|---------|-------------|
| `thresholds` | "auto" | Bin count, edges, or method |
| `interval` | - | Alternative to thresholds |
| `domain` | - | Omit values outside range |
| `cumulative` | 0 | 1 for cumulative, -1 for reverse |

## Threshold Methods

- `"auto"` - Scott's rule (default)
- `"freedman-diaconis"` - Freedman-Diaconis rule
- `"scott"` - Scott's rule
- `"sturges"` - Sturges' formula
- Number - Approximate bin count
- Array - Explicit bin edges
- Interval - Time or numeric interval

## Notes

- Outputs channels like x1, x2, y1, y2 for bin boundaries
- Use `domain` to exclude outliers
- Subdivide bins using z, fill, or stroke channels
- Works with faceting for small multiples

Files in this skill

  • README.md822 B
  • skill.md2.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.