Genie Discord forum

Author AvatarDale
4/10/2023, 10:38:45 PM

I am creating a webapp that loads an image and outputs a heatmap of that image. How would I create a PlotData() variable for a heatmap? The code below attempts this in two different ways, but neither attempt works

# /dashboard.jl
slice = rand(84, 84)
image_viewer1 = PlotData(z=slice, plot="heatmap")
image_viewer2 = PlotData(slice, plot="heatmap")

# /ui.jl

Error 1:

MethodError: no method matching (Vector)(::Matrix{Float64})

Error 2:

MethodError: no method matching StipplePlotly.Charts.PlotData(::Matrix{Float64}; plot="heatmap")
Author AvatarPere
4/11/2023, 9:03:43 AM

You need to use the correct type from StipplePlotly.Charts, and use an array of arrays instead of a matrix. Here's an example:

The relevant code is:

 vec_matrix = [similarity_matrix[:,i] for i in 1:n_words]

hmap = PlotData(
                      z = similarity_matrix,
                      x = tokens,
                      y = tokens,
                      plot = StipplePlotly.Charts.PLOT_TYPE_HEATMAP,
Author AvatarDale
4/14/2023, 1:34:11 AM

Thanks, that repo will be super helpful. Is there anything unique about StipplePlotly and PlotlyJS with regards to syntax? If I set it up to work with PlotlyJS, the same code should essentially work with StipplePlotly, right?