You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/routes/transforms/jitter/+page.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Jitter transform
3
3
---
4
4
5
-
The **jitter transform** adds random noise to data points, which is useful for revealing overlapping points in scatter plots and reducing overplotting.
5
+
The **jitter transform** adds random noise to data points, which is useful for revealing overlapping points in scatter plots and reducing overplotting.
6
6
7
7
:::info
8
8
**Note:** The jitter transform works in data coordinates. To jitter in screen coordinates, you can use the `dx` and `dy` mark properties instead.
@@ -64,26 +64,26 @@ The jitter transform spreads out overlapping points by adding random noise. This
64
64
The jitter transform accepts the following options:
65
65
66
66
-**type**: Distribution type, either `'uniform'` (default) or `'normal'`
67
-
-`uniform`: Evenly distributed points within range [-width, width]
68
-
-`normal`: Normal distribution centered at 0 with standard deviation `std`
67
+
-`uniform`: Evenly distributed points within range [-width, width]
68
+
-`normal`: Normal distribution centered at 0 with standard deviation `std`
69
69
-**width**: Width of the uniform distribution (default: `0.35`); used when `type` is `'uniform'`
70
-
- For numeric data: A number representing the range on either side of the original value
71
-
- For date data: A time interval string (e.g., `'1 month'`, `'2 weeks'`, `'3 days'`)
70
+
- For numeric data: A number representing the range on either side of the original value
71
+
- For date data: A time interval string (e.g., `'1 month'`, `'2 weeks'`, `'3 days'`)
72
72
-**std**: Standard deviation for the normal distribution (default: `0.15`); used when `type` is `'normal'`
73
-
- For numeric data: A number representing the standard deviation
74
-
- For date data: A time interval string (e.g., `'1 month'`, `'2 weeks'`, `'3 days'`)
73
+
- For numeric data: A number representing the standard deviation
74
+
- For date data: A time interval string (e.g., `'1 month'`, `'2 weeks'`, `'3 days'`)
75
75
-**source**: Optional random number source that produces values in range [0,1)
76
-
- Useful for deterministic jittering (testing or reproducibility)
77
-
- Can be used with d3's random generators: `randomLcg()` from d3-random
76
+
- Useful for deterministic jittering (testing or reproducibility)
77
+
- Can be used with d3's random generators: `randomLcg()` from d3-random
78
78
79
79
The following time interval strings are supported for temporal jittering:
80
+
80
81
-`'1 day'`, `'3 days'`
81
82
-`'1 week'`, `'2 weeks'`, `'3 weeks'`
82
-
-`'1 month'`, `'2 months'`
83
+
-`'1 month'`, `'2 months'`
83
84
-`'1 quarter'`
84
85
-`'1 year'`
85
86
86
-
87
87
## jitterX
88
88
89
89
Jitters along the x dimension:
@@ -108,7 +108,6 @@ Jitters along the y dimension:
108
108
)} />
109
109
```
110
110
111
-
112
111
## Temporal jittering
113
112
114
113
Jittering also works for temporal data. When jittering Date objects, random time offsets are added to each date value:
@@ -182,11 +181,11 @@ For reproducible jittering or specialized random distributions, you can provide
182
181
<script>
183
182
import { Plot, Dot, jitterX } from 'svelteplot';
184
183
import { randomLcg } from 'd3-random';
185
-
184
+
186
185
// Create a deterministic random source with a seed
187
186
const seed = 42;
188
187
const myRandomSource = randomLcg(seed);
189
-
188
+
190
189
// This will produce the same jitter pattern every time
191
190
const jitteredProps = jitterX(
192
191
{ data, x: 'value' },
@@ -200,6 +199,7 @@ For reproducible jittering or specialized random distributions, you can provide
200
199
```
201
200
202
201
This is particularly useful for:
202
+
203
203
- Testing and debugging visualizations
204
204
- Creating reproducible figures for publications
205
205
- Ensuring consistent visual appearance across renders
0 commit comments