The tickCount axis parameter allows to set an approximate number of ticks, as per the docs:
A desired number of ticks, for axes visualizing quantitative scales. The resulting number may be different so that values are "nice" (multiples of 2, 5, 10) and lie within the underlying scale's range.
Here is an example where changing the parameter to 3 only gives 2 axis ticks.
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "A scatterplot showing horsepower and miles per gallons for various cars.",
"data": {"url": "data/cars.json"},
"mark": "point",
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative", "axis": {"tickCount": 3}},
"y": {"field": "Miles_per_Gallon", "type": "quantitative"}
}
}
Open the Chart in the Vega Editor
While I understand that it is nice to have a default that is rounded to a convenient well-behaved value, I think the expectation and desired outcome when starting to modify from this default, is often to be able to set an exact tick number. Is there any way to override the "nice" rounding behavior and set an exact number of ticks?