clearseplex
clearseplex

Reputation: 729

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.

Upvotes: 7

Views: 25051

Answers (1)

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42244

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")

enter image description here

Upvotes: 17

Related Questions