How to make my colormap plot smoother?

52 views (last 30 days)
I am trying to create colormap plot. I have attempted to use the "imagesc" function and the "pcolor" function, but both functions generate pixelated, granular plots.
What can I do to make the plots look smoother?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 9 Feb 2021
Several methods can be used to make the plot smoother. Each method would create slightly different looking plots.
You can select the method that creates plots that best fit your needs.
MATLAB R2019a and older
There are two ways to create smoother plots with "pcolor":
1. For "pcolor", there is an property called "shading". When "shading" is set to "interp", it generates a smoother plot. For example:
C = hadamard(20);
pcolor(C)
colormap(gray(2))
axis ij
axis square
shading interp
Compare the results with and without "shading interp".
2. You can perform interpolation on the data first, and then plot with "pcolor". Specifically, use "imresize" to scale up the data first with "method" set to any interpolation method. Then, create the plot with "pcolor" using the new data. The plot would be smoother than the original plot. For example:
C = [5 13 9 7 12; 11 2 14 8 10; 6 1 3 4 15];
C = imresize(C, 2, 'bilinear');
s = pcolor(C);
Compare the results with and without "imresize".
MATLAB R2019b and newer
If you have MATLAB R2019b or newer, there is an additional way to create smoother plots with "imagesc". "imagesc" has a property called "Interpolation". When "Interpolation" is set to "bilinear", it creates a smoother plot. For example:
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
imagesc(C, 'Interpolation', 'bilinear')
colorbar
Compare the results with and without "Interpolation" being set to "bilinear".

More Answers (0)

Categories

Find more on Color and Styling in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!