Override Plot scales with D3 scales? (looking for d3.scaleDivergingSymlog)

I would like to use d3.scaleDivergingSymlog as a scale for an Observable Plot color scale. The scale options currently look like this:

color: {
      type: "symlog",
      scheme: "rdylgn",
      domain: [-99.9, 80, 4993600]
    }

Because my data is lopsided, the point at which the color scale naturally diverges (without specifying the domain above) is nowhere near zero. I thought that specifying the domain and adding “0” in the middle of it would help, but it still ended up a little lopsided somehow. “80” has the yellow portion of the color scale appearing to be around 0. It would be great to use an actual diverging symlog scale, but it seems that’s not an option. The following does not work:

color: {
type: “divergingSymlog”,
scheme: “rdylgn”,
domain: [-99.9, 0, 4993600]
}

Any help would be appreciated. Thanks!

this use-case should be served by Add diverging-log et al. by mbostock · Pull Request #368 · observablehq/plot · GitHub
Please try it at Plot diverging-symlog (#368) / Fil / Observable (you can download the build from the file attachment).

The pivot is specified as a separate option for diverging scales; the domain is still two elements. For example:

color: {
  type: "diverging",
  scheme: "rdylgn",
  domain: [-99.9, 4993600],
  pivot: 80
}

If you can use the min and max (extent) as the domain, then you can remove the domain option entirely.

However, as @Fil noted, we haven’t yet released support for diverging log and symlog scales. You could workaround this for now by transforming the data yourself.

Thanks you both! The scale in attachment works (for my purposes, without specifying a pivot or a domain). Looking forward to having it officially supported.

P.S. Thanks for D3 :heart:; it’s the foundation of my professional life.

4 Likes