Plot: binning with log scale?

I have some data that is very skewed towards one side. So it ends up grouping nearly everything into a single bin, and then the rest of the data is spread out among the other bins, making it kind of hard to read. Any ideas on how I can incorporate a log scale of the axes while still using binning? When I try the naive way, my dots are large single dots for the large bins, and then they get smaller as the log scale increases. I would like to have more uniform-sized dots but still use the log scale so it all fits on the graph:

Code is here: Does The Algorithm Hate Your Friends? / Tyler Freeman / Observable

1 Like

I’m also trying to split up that first bin using a log scale so we can see more nuance with the first 500 values, and still compare them to the later bins which have much fewer entries. But when I try using bin with log scales again, it gets messed up:

Is this a bug or am I using bin wrong? Why is the y axis so tall but no values reach that high?

You can apply a log transform to the data first, and then bin that. There’s an example of this in the Plot repo:

Something like this?

Plot.rect(
  snitchesWithFollowers.filter((d) => d.likes > 0 && d.retweets > 0),
  Plot.bin(
    { fill: "count" },
    { x: (d) => Math.log10(d.likes), y: (d) => Math.log10(d.retweets) }
  )
).plot()
1 Like