Is there a way to get the frequency value in the tip pointer title?

I’m trying different kinds of graphs for statistics about my photos.

For example, I wanted to plot the “Frequency of apertures along the years”:

I would like to show the number of photos with each aperture in the plot tip pointer title, for example “5 photos with aperture ƒ/9.6 in​2019”. (I don’t know what’s the real number here)

But I didn’t find any way.

I tried with ${d.count} or ${d.frequency} for example, without success.

How am I supposed to show such information?

Thanks.

The easiest thing to do is use the tip mark option, like so:

Plot.dot(photosData, Plot.group({r: "count", fill: "count"}, {x: "year", y: "aperture", tip: true}))

If you want to manually format the tip, you can set a reducer on the title channel using the first (outputs) argument to the group transform:

Plot.dot(
  photosData,
  Plot.group(
    {
      r: "count",
      fill: "count",
      title: (data, { x, y }) => `${data.length} photos with aperture ${data[0].readable_aperture} in ${x}`
    },
    { x: "year", y: "aperture", tip: true }
  )
)

In general, if you want to access data that is derived from a transform, you do so in a reducer (the output of the transform). "count" is a built-in reducer, but you can implement your own reducers as functions.

Thanks a lot for the details, I better understand now. :folded_hands:

And it looks like I don’t have to add a tip mark anymore, with this solution.