How to plot a matrix as an image (greyscale)

Hi guys, my question is how to plot a matrix as an image in greyscale?

I saw the version with ‘Gadfly’ and worked for me but it was in bluescale.

Thank you very much in advance for your support.

Cheers.

Ergnoor

With Plots, e.g., you’d do

using Colors, Plots
plot(Gray.(mymatrix))

or

using Plots
heatmap(mymatrix, color = :greys) #which will also give you a color legend

Most plotting packages should do something similar

5 Likes

@mkborregaard Hi Michael and thank you very much. Cheers. Ergnoor

1 Like

Just for completeness… in Gaston you can do:

using Gaston
M = [ 1 2 3 ; 3 2 1; 4 8 2];
set(palette="gray")
imagesc(M)
1 Like

Here you assume that mymatrix has values between 0 and 1?