Extend y-axis one tick beyond domain

In Observable Plot, is there a way to set the axisY mark to include just one more tick beyond the extent of the domain? For example, I want to use the New York Times style axes, but I want the wider label at the top to be above the data. So instead of this:

I would like it to look like this:

Right now I am pretty much guessing and checking how to update the axis’ domain to get it to add an additional tick, but it would be great if there were a more explicit way of doing it.

Example notebook

How about:

domain: [0, d3.max(data, (d) => d[1]) + 1]

assuming that you defined your data as data.

Try this:

y: { nice: 5 }

The nice option can be specified as a number corresponding to the desired number of ticks. If you specify it as nice: true, it (currently) assumes there are 10 ticks, which isn’t accurate in this case. Using a lower number will use chunkier nicing.

Ah yes! I somehow missed the “(or a tick count)” in the documentation for nice on this page

Brilliant! I think using nice will work well for my needs. Thank you both for taking time to respond!

1 Like