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

enter image description here

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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.

You Might Also Like