observablehq / plot

A concise API for exploratory data visualization implementing a layered grammar of graphics
https://observablehq.com/plot/
ISC License
4.41k stars 176 forks source link

Specify the min or max of a quantitative scale without specifying the whole extent #1577

Open Fil opened 1 year ago

Fil commented 1 year ago

Possibilities:

min and max is more straightforward, but we'd have to decide what happens when people specify both a min and an explicit domain (a warning maybe?).

domain as a function opens lots of other possibilities (like custom “nicing”), which might be a pro or a con.

Fil commented 1 year ago

Another feature would be to allow the user to specify values that must be in the domain; for example when you don't know exactly what the values will be in your dataset, but you absolutely want the domain to include [0, 10] — maybe just to create a scale that doesn't show “0, 0.5, 1, 1.5, 2.0” as ticks (related: #355 #1268).

Hvass-Labs commented 11 months ago

This suggestion seems related to your 2nd comment. But just to be sure we mean the same thing:

It would be useful if I could specify values that must be included on each axis, but the axis-ranges won't change unless necessary. For example:

Plot.plot({ x: { include: [10, 30] },
            y: { include: [-1000, +1000] }, ... });

If the data has x-values between 5 and 40, then the x-range won't change. But if the data only has x-values between 15 and 20, then the x-axis will be expanded to the desired range between 10 and 30. Similar for the y-range.

Fil commented 9 months ago

See also https://github.com/observablehq/plot/discussions/1976#discussioncomment-8225654