Skip to content

Raster-plot using array channels #1990

Answered by Fil
Hvass-Labs asked this question in Q&A
Discussion options

You must be logged in to vote

As I'm suggesting in #1989 you could use {length: 12345} as the data. But you also need all the channels to have the same length, so starting from the same dataset this would be:

Plot.raster(
  { length: data.width * data.height },
  {
    x: (d, i) => data.x[i % data.width],
    y: (d, i) => data.y[Math.floor(i / data.width)],
    fill: data.fill.flat(),
    width: data.width,
    height: data.height,
    imageRendering: "pixelated"
  }
).plot({ x: { tickFormat: "s" }, grid: true })

(PS: no one is "really" a JavaScript programmer: everyone's always learning, and that is an ongoing process for everyone.)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Hvass-Labs
Comment options

Answer selected by Hvass-Labs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants