How can I print the heatmap as grayscale?

A = rand(5)
heatmap(A, option)
I want to see heatmap in grayscale.
OR
Can I use 'saveas' to save in grayscale?

 Accepted Answer

heatmap(A)
colormap(gray)

4 Comments

Then, how do you invert the color?
heatmap(A)
colormap('gray')
cmap = colormap; % get current color map
cmap1 = cmap(256:-1:1,:); % reverse color map
colormap(cmap1)
Thank you sir !!!

Sign in to comment.

More Answers (1)

As of R2021a the exportgraphics function supports a Colorspace option for both image and vector formats that you can use to generate grayscale output:
exportgraphics(gca, 'output.jpg', 'colorspace', 'gray');
exportgraphics(gca, 'output.pdf', 'colorspace', 'gray');

Categories

Asked:

on 12 Apr 2021

Answered:

on 6 Dec 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!