I have MNIST data I have loaded into OJS, its essentially a list of 28x28 (2D) arrays.
I have an input slider that selects the index, which I use to select which of the 28x28 array I want to display. However, I am not sure how to go about displaying the 2D array as an image.
Here’s how I would use that imshow function to display the MNIST digits in Observable:
You can build and style HTML in a number of ways with Observable so, if you know HTML and CSS, you can display it in almost any way you want. I chose to build a DIV with Javascript and return that. Here’s the result:
We’ve recently been working on a new raster mark for Plot. You can check out this branch if you’d like to try it:
@Fil has written up some of our thinking here, and also demonstrated a couple ways of doing this using the rect and dot marks:
Using individual SVG elements per datum, as the rect or dot mark does, starts to get slow with large grids. That might be okay for a 28×28 grid, but the purpose of the propose raster mark is to make this much more efficient by using canvas. We’d love feedback on the proposed API if you are interested.