How to Plot Heatmap in Julia

I have a (21,100)-array and want to plot it as 2D-Histogram (heatmap). If I plot it naively with histogram2d(A, nbins= 20) it only plots the first 21 points.

I tried to loop it, but then I had 100 histograms with 21 points. Another idea would be to put the data in a (2100)-array but this seems like a bad idea.

Addition: I have a scatter plot/data and want it shown as a heatmap. The more points in one bin the "darker" the color. So I have 21 x-values each with 100 y-values.

3

1 Answer

Here it is a typical scenario for a heatmap plot:

using Plots
gr()
data = rand(21,100)
heatmap(1:size(data,1),
    1:size(data,2), data,
    c=cgrad([:blue, :white,:red, :yellow]),
    xlabel="x values", ylabel="y values",
    title="My title")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest