This message was deleted.
# help
s
This message was deleted.
m
I am trying to see how different color schemes behave under different color vision deficiencies. This is what I've plotted so far:
produced with the following code:
Copy code
{
  const none = (t) => culori.formatHex(t);
  const greyscale = (t) => culori.formatHex(culori.filterGrayscale()(t));
  const deuteranopia = (t) =>
    culori.formatHex(culori.filterDeficiencyDeuter()(t));
  const tritanopia = (t) => culori.formatHex(culori.filterDeficiencyTrit()(t));
  const protanopia = (t) => culori.formatHex(culori.filterDeficiencyProt()(t));

  const turbo = (t) => d3.interpolateTurbo(t);
  const viridis = (t) => d3.interpolateViridis(t);
  const plasma = (t) => d3.interpolatePlasma(t);

  return Plot.plot({
    color: { type: "identity" },
    nice: true,
    aspectRatio: 322 / 420,
    fx: { tickFormat: (f) => f?.name },
    fy: { tickFormat: (f) => f?.name },
    marks: [
      Plot.raster({
        fill: (x, y, { fx, fy }) => {
          console.log(fx, fy);
          if (fx && fy) {
            return fx(
              fy(monaLisaLightness[Math.floor(322 - y)][Math.floor(x)])
            );
          }
        },
        fx: [none, greyscale, deuteranopia, tritanopia, protanopia],
        fy: [turbo, viridis, plasma],
        x1: 0,
        y1: 0,
        x2: 420,
        y2: 322
      })
    ]
  });
}
you'll notice a few things: 1. some of the faceting works, and the functions are getting passed down just fine
2. you'll see that
console.log
in the
fill
function? Well it turns out that
fx
and
fy
are
undefined
a lot
in fact, the squares that nothing was rendered in corresponds to when
fx
and
fy
were
undefined
f
(I don't have an answer, I just wanna say thanks for sticking to this ๐Ÿงต format! ๐Ÿ™)
๐Ÿ˜ 1
โž• 1
๐Ÿ™ 1
Can you share this as a notebook?
m
sure
f
My first instinct would be to plot one of the broken combos in a separate cell to see the produced values
m
yep, works
using
Copy code
fx: [protanopia],
        fy: [turbo],
f
something about the domain perhaps?
m
maaaaybe? I dunno what could be wrong with the domain configuration given that its working with some of the images ๐Ÿ˜ฌ
f
what's also noticeable is that every row and every column only has one entry, and that repeating the functions in the domain doesn't work either
m
okay I made a subtle error with the raster bounding but fixing that didn't affect the bug
f
yeah, tbh I have no idea what's wrong
m
I think it may be time for me to look at the source code because I'm worried this is a bug lol
f
I think I'd try to build back to only pass through the initial values, ignoring the actual domain
I give up. I tried to make sense of the faceting based on https://observablehq.com/@observablehq/plot-raster?collection=@observablehq/plot#cell-762 (note how each domain has 4 values?), but I don't see a clear pattern. Maybe @Fil can help?
OK, I've grokked it. You need to supply domain values for every facet:
Copy code
fx: [
          none, greyscale, deuteranopia, tritanopia, protanopia,
          none, greyscale, deuteranopia, tritanopia, protanopia,
          none, greyscale, deuteranopia, tritanopia, protanopia,
        ],
        fy: [
          turbo, viridis, plasma,
          turbo, viridis, plasma,
          turbo, viridis, plasma,
          turbo, viridis, plasma,
          turbo, viridis, plasma,
        ],
m
ohhhhhhh!!!
that's really interesting
f
you could use d3.cross to make the matrix
m
sweeeet
๐Ÿ™Œ๐Ÿป 1
thanks folks!
f
awesome notebook
โค๏ธ 1