{ "cells": [ { "cell_type": "markdown", "id": "f0563644", "metadata": {}, "source": [ "# PlotlyJS.image from UInt8 arrays" ] }, { "cell_type": "markdown", "id": "1394cd20", "metadata": {}, "source": [ "## How to display an Array(UInt8, 3), as image" ] }, { "cell_type": "markdown", "id": "e46bf04c", "metadata": {}, "source": [ "Besides the case when is provided the `source`, the trace `image` can display exclusively an `Array(UInt8, 3)` of size equal (3, nrows, ncolumns) \n", "or (4, nrows, ncolumns).\n", "In the former case we are setting `colormodel=\"rgb\"`, while in the latter one, `colormodel=\"rgba\"`.\n", " Since Julia arrays are column major ordered, and the json serialization of an array, `myarr`, of size (d, nrows, ncolumns), d=3, 4, \n", " performed by PlotlyJS, has a bug, it is necessary to permute nrows and ncolumns.\n", " More precisely we have to pass to `image` definition `z=permutedims(myarr, (1, 3, 2))`." ] }, { "cell_type": "code", "execution_count": 1, "id": "8608e8dd", "metadata": {}, "outputs": [ { "data": { "application/vnd.webio.node+json": { "children": [], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": {}, "type": "node" }, "text/html": [ "
The WebIO Jupyter extension was not detected. See the\n", "\n", " WebIO Jupyter integration documentation\n", "\n", "for more information.\n", "