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: docs/features/facets.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Faceting partitions data by ordinal or categorical value and then repeats a plot
25
25
26
26
For example, below we recreate the Trellis display (“reminiscent of garden trelliswork”) of [Becker *et al.*](https://hci.stanford.edu/courses/cs448b/papers/becker-trellis-jcgs.pdf) using the dot’s **fy** channel to declare vertical↕︎ facets, showing the yields of several varieties of barley across several sites for the years <span:style="{borderBottom: `solid 2px ${d3.schemeTableau10[0]}`}">1931</span> and <span:style="{borderBottom: `solid 2px ${d3.schemeTableau10[1]}`}">1932</span>.
@@ -59,7 +59,7 @@ Use the [frame mark](../marks/frame.md) for stronger visual separation of facets
59
59
60
60
The chart above reveals a likely data collection error: the years appear to be reversed for the Morris site as it is the only site where the yields in <span:style="{borderBottom: `solid 2px ${d3.schemeTableau10[1]}`}">1932</span> were higher than in <span:style="{borderBottom: `solid 2px ${d3.schemeTableau10[0]}`}">1931</span>. The anomaly in Morris is more obvious if we use directed arrows to show the year-over-year change. The [group transform](../transforms/group.md) groups the observations by site and variety to compute the change.
@@ -94,7 +94,7 @@ Here the sort order has changed slightly: the *y* and *fy* domains are sorted by
94
94
95
95
Faceting requires ordinal or categorical data because there are a discrete number of facets; the associated *fx* and *fy* scales are [band scales](./scales.md#discrete-position). Quantitative or temporal data can be made ordinal by binning, say using [Math.floor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor). Or, use the [**interval** scale option](../transforms/interval.md) on the *fx* or *fy* scale. Below, we produce a [box plot](../marks/box.md) of the weights (in kilograms) of Olympic athletes, faceted by height binned at a 10cm (0.1 meter) interval.
@@ -116,7 +116,7 @@ If you are interested in automatic faceting for quantitative data, please upvote
116
116
117
117
When both **fx** and **fy** channels are specified, two-dimensional faceting results, as in the faceted scatterplot of penguin culmen measurements below. The horizontal↔︎ facet shows sex (with the rightmost column representing penguins whose *sex* field is null, indicating missing data), while the vertical↕︎ facet shows species.
You can mix-and-match faceted and non-faceted marks within the same plot. The non-faceted marks will be repeated across all facets. This is useful for decoration marks, such as a [frame](../marks/frame.md), and also for context: below, the entire population of penguins is repeated in each facet as small gray dots, making it easier to see how each facet compares to the whole.
@@ -206,7 +206,7 @@ This example uses an [immediately-invoked function expression (IIFE)](https://de
206
206
207
207
The above chart also demonstrates faceted annotations, using a [text mark](../marks/text.md) to label the facet in lieu of facet axes. Below, we apply a single text annotation to the *Adelie* facet by setting the **fy** channel to a single-element array parallel to the data.
Given a *date*, returns the shortest equivalent ISO 8601 UTC string. If the given *date* is not valid, returns `"Invalid Date"`. See [isoformat](https://github.com/mbostock/isoformat).
Copy file name to clipboardExpand all lines: docs/features/legends.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ onMounted(() => {
28
28
29
29
Plot can generate **legends** for *color*, *opacity*, and *symbol*[scales](./scales.md). For example, the scatterplot below of body measurements of Olympic athletes includes a legend for its *color* scale, allowing the meaning of color to be interpreted by the reader. (The axes similarly document the meaning of the *x* and *y* position scales.)
The legend above is a *swatches* legend because the *color* scale is *ordinal* (with a *categorical* scheme). When the *color* scale is continuous, a *ramp* legend with a smooth gradient is generated instead. The plot below of global average surface temperature ([GISTEMP](https://data.giss.nasa.gov/gistemp/)) uses a *diverging**color* scale to indicate the deviation from the 1951–1980 average in degrees Celsius.
@@ -78,7 +78,7 @@ Plot does not yet generate legends for the *r* (radius) scale or the *length* sc
78
78
79
79
If the **legend**[scale option](./scales.md#scale-options) is true, the default legend will be produced for the scale; otherwise, the meaning of the **legend** option depends on the scale: for quantitative color scales, it defaults to *ramp* but may be set to *swatches* for a discrete scale (most commonly for *threshold* color scales); for *ordinal**color* scales and *symbol* scales, only the *swatches* value is supported.
80
80
81
-
<!-- TODO Describe the color and opacity options, and demo the symbol legend with a redundant color encoding. -->
81
+
<!-- TODO Describe the color and opacity options. -->
82
82
83
83
Categorical and ordinal color legends are rendered as swatches, unless the **legend** option is set to *ramp*. The swatches can be configured with the following options:
Copy file name to clipboardExpand all lines: docs/features/plots.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ onMounted(() => {
25
25
26
26
To render a **plot** in Observable Plot, call [plot](#plot-options) (typically as `Plot.plot`), passing in the desired *options*. This function returns an SVG or HTML figure element.
@@ -70,7 +70,7 @@ Rather than baking data into JavaScript, use [JSON](https://en.wikipedia.org/wik
70
70
71
71
To use data with Plot, pass the data as the first argument to the mark constructor. We can then assign columns of data such as *Date* and *Close* to visual properties of the mark (or “channels”) such as horizontal↔︎ position **x** and vertical↕︎ position **y**.
A plot can have multiple marks, and each mark has its own data. For example, say we had a similar table `goog` representing the daily price of Google stock for the same period. Below, the <spanstyle="border-bottom: solid2pxvar(--vp-c-red);">red</span> line represents Google stock, while the <spanstyle="border-bottom: solid2pxvar(--vp-c-blue);">blue</span> line represents Apple stock.
@@ -100,7 +100,7 @@ When comparing the performance of different stocks, we typically want to normali
100
100
101
101
Alternatively, the tables can be combined, say with a *Symbol* column to distinguish AAPL from GOOG. This allows the use of a categorical *color* scale and legend.
@@ -120,7 +120,7 @@ Each mark may be a nested array of marks, allowing composition. Marks may also b
120
120
121
121
Marks are drawn in the given order, with the last mark drawn on top. For example, below <spanstyle="border-bottom: solid2pxvar(--vp-c-green);">green</span> bars are drawn on top of <spanstyle="border-bottom: solid2px;">{{dark ? "white" : "black"}}</span> bars.
If a **caption** is specified, Plot.plot wraps the generated SVG element in an HTML figure element with a figcaption, returning the figure. To specify an HTML caption, the caption can be specified as an HTML element, say using the [`html` tagged template literal](http://github.com/observablehq/htl); otherwise, the specified string represents text that will be escaped as needed.
Copy file name to clipboardExpand all lines: docs/features/scales.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ onMounted(() => {
40
40
41
41
When visualizing this data with a [line](../marks/line.md), the *x* scale is responsible for mapping dates to horizontal↔︎ positions. For example, 1880-01-01 might be mapped to *x* = 40 (on the left) and 2016-12-01 might be mapped to *x* = 620 (on the right). Likewise, the *y* scale maps temperature anomalies to vertical↕︎ positions.
Scales aren’t limited to horizontal and vertical position. They can also output to color, radius, length, opacity, and more. For example if we switch to a [rule](../marks/rule.md) and use the **stroke** channel instead of **y**, we get a one-dimensional heatmap:
Within a given [plot](./plots.md), marks share scales. For example, if a plot has two line marks, such as the lines below visualizing the daily closing price of <spanstyle="border-bottom: solid2pxvar(--vp-c-red);">Google</span> and <spanstyle="border-bottom: solid2pxvar(--vp-c-blue);">Apple</span> stock, both share the same *x* and *y* scales for a consistent encoding.
@@ -118,23 +118,23 @@ Let’s look at some examples to make this less abstract.
118
118
119
119
The domain of a quantitative scale is a continuous extent [*min*, *max*] where *min* and *max* are numbers, such as temperatures. Below, the first domain value (*x* = 0) corresponds to the left side of the plot while the second (*x* = 100) corresponds to the right side.
Alternatively, use the **reverse** option; this is convenient when the domain is implied from data rather than specified explicitly. (We’ll cover implied domains in more detail in the *inference* section below.)
@@ -144,7 +144,7 @@ If the domain is dates, Plot will default to a UTC scale. This is a linear scale
144
144
145
145
<!-- Plot doesn’t parse dates; convert your strings to [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) instances with [d3.utcParse](https://github.com/d3/d3-time-format#utcParse) or [d3.autoType](https://github.com/d3/d3-dsv#autoType). -->
@@ -156,61 +156,61 @@ We are working on better multi-line ticks for time scales; please upvote [#1285]
156
156
157
157
To force a UTC scale, say when the data is milliseconds since UNIX epoch rather than Date instances, pass *utc* as the **type** option. Though we recommend coercing strings and numbers to more specific types when you load data, rather than relying on scales to do it.
When plotting values that vary widely, such as the luminosity of stars in an [HR diagram](https://observablehq.com/@mbostock/hertzsprung-russell-diagram), a *log* scale may improve readability. Log scales default to base-10 ticks with SI-prefix notation.
If you prefer conventional notation, you can specify the **tickFormat** option to change the behavior of the axis. The **tickFormat** option can either be a [d3.format](https://github.com/d3/d3-format) string or a function that takes a tick value and returns the corresponding string. Note, however, that this may result in overlapping text.
The domain of a log scale cannot include (or cross) zero; for this, consider a [bi-symmetric log](https://github.com/d3/d3-scale#symlog-scales) scale instead.
@@ -224,15 +224,15 @@ Sadly, not all data is continuous: some data is merely ordinal, such as t-shirt
224
224
225
225
A *point* scale divides space into uniformly-spaced discrete values. It is commonly used for scatterplots (a [dot mark](../marks/dot.md)) of ordinal data. It is the default scale type for ordinal data on the *x* and *y* scale.
A band scale divides space into uniformly-spaced and -sized discrete intervals. It is commonly used for bar charts (bar marks). To show the bands below, we use a [cell](../marks/cell.md) instead of a [grid](../marks/grid.md).
Below we again show observed global surface temperatures. The reversed *BuRd* color scheme is used since <span:style="{borderBottom: `solid 2px ${d3.interpolateRdBu(0.9)}`}">blue</span> and <span:style="{borderBottom: `solid 2px ${d3.interpolateRdBu(0.1)}`}">red</span> are semantically associated with cold and hot, respectively.
@@ -568,7 +568,7 @@ All position scales (*x*, *y*, *fx*, and *fy*) have implicit automatic ranges ba
568
568
569
569
The **transform** scale option allows you to apply a function to all values before they are passed through the scale. This is convenient for transforming a scale’s data, say to convert to thousands or between temperature units.
0 commit comments