Raster-plot using array channels #1990
-
How can I make a raster-plot using array channels? My data is roughly:
I'm trying to make the plot as follows, but I don't know which data / index (?) to pass instead of 12345? The following just gives an empty plot:
If instead I convert the data to an array of dicts in roughly this format:
then I can plot it just fine as follows:
But I would prefer to skip the conversion step and use the arrays directly as input channels. I've made a little Notebook to demonstrate this. Sorry if it's a bit messy, I'm not really a Java-script programmer, and I think HQ uses syntax I'm not familiar with. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
As I'm suggesting in #1989 you could use 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.) |
Beta Was this translation helpful? Give feedback.
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:(PS: no one is "really" a JavaScript programmer: everyone's always learning, and that is an ongoing process for everyone.)