Plot: get formatted axis tick values

Plot does a great job dynamically computing ticks values and formats. I want to use the strings of the x and y tick values.

In this notebook I’m able to identify the locations of each tick and (with a good bit of copying and pasting) apply the formatter.

This is pretty cumbersome, and I can’t quite get it working for dates finally got it working for dates. Is there a better way to get the formatted tick values from a Plot?

:wave:

I don’t have an answer for you, sadly, but I am very curious what you are trying to do with the formatted axis tick values.

Fun to see you here, @Cobus - I’m trying to compute better (updated) margins and axis tick rotations so that the ticks don’t get cutoff or overlap.

FWIW, My current approach is to render the SVG and then use a querySelector to grab the labels:

const xTickLabels = node.querySelectorAll('[aria-label="x-axis tick label"] text')

You can use a Plot.axisX mark with a render transform. I’m sending you a suggestion.

Thanks @Fil !

@Fil could you please also send me this suggestion? My use case is that I want to know these autogenerated tick values in order to do some unit testing on the way i am rounding values.

@mishatsvelik You can find the changes here: Comparing Get axis tick values to Get axis tick values | Observable