Why are there missing pixels in my "heat map" plot using pcolorm?
Afficher commentaires plus anciens
I am using pcolorm to produce a map showing annual mean precipitation in part of South America.
I have found that pcolorm commonly shows dropped pixels around the perimeter of the "heat map", as shown in the attached example.
The map projection is Miller. The gridded data (P_Annual) is complete, and the lat, lon limits of the map are equal to the limits of the data.

4 commentaires
Mark Brandon
le 4 Nov 2022
Déplacé(e) : Star Strider
le 4 Nov 2022
Mark Brandon
le 5 Nov 2022
Modifié(e) : Mark Brandon
le 5 Nov 2022
Andrew Stevens
le 12 Oct 2023
Rather than editing the source code, another approach I have found to this problem is to calculate the projected coordinates and use the regular version of the function (in this case pcolor instead of pcolorm). After you create the map axes, something like this:
[x,y]=projfwd(getm(gca),lat,lon)
pcolor(x,y,yourz)
I have found the mapping toolbox versions of the code to generally be less reliable than their non mapping tbx counterparts.
Mark Brandon
le 12 Oct 2023
Réponses (2)
Suvansh Arora
le 8 Nov 2022
0 votes
One possible issue is the dimension of variables and I think resolving that will solve your issue.
- Expected dimensions for “lat” is [121 1].
- Expected dimensions for “lon” is [61 1].
Please follow the documentation below for more information about the dimensions of “x’, “y” ans and “c” in “pcolor(x, y, c)” function:
4 commentaires
Mark Brandon
le 8 Nov 2022
Suvansh Arora
le 9 Nov 2022
You can use the grid vectors, but please take care of the dimensions in your ".m" script.
Current Dimensions:
>> size(lat)
ans =
61 1
>> size(lon)
ans =
121 1
Expected Dimensions in accordance with documentation:
>> size(lon)
ans =
61 1
>> size(lat)
ans =
121 1
Just replace all the occurences of "lat" with "lon", and "lot" with "lan". you will get the desired heat map without any missing pixels.
Mark Brandon
le 9 Nov 2022
Suvansh Arora
le 11 Nov 2022
I would recommend changing your dataset in a way that aligns to the size requirements of MATLAB modules. However, you are right in pointing out the issue in the “pcolorm” module and will let the concerned team know about this issue.
As you already have a possible workaround to unblock yourself, I am mentioning below some other workarounds that you may try:
- Reversing “lat” and “lon” in the code “reverse.m” shows the “heatmap” with changed DMS (degrees minutes seconds).
- Using “heatmap” requires number of “lat” values to be same as the number of columns in “P_Annual”, please follow the “heatmap.m” for more details.
Mark Brandon
le 11 Nov 2022
0 votes
2 commentaires
Suvansh Arora
le 23 Nov 2022
Hello Mark,
I have informed the team responsible for Mapping Toolbox to take care of this issue. However, if you would like to have any further assistance, please contact MathWorks Support through this link: Contact_Us
Suvansh Arora
le 21 Déc 2022
Modifié(e) : Suvansh Arora
le 21 Déc 2022
To display the heatmap without drop in pixels, we can use the 'geoshow' function.
[lat, lon] = ndgrid(lat, lon); % Replace gridVectors with grids
geoshow(lat, lon, P_Annual*365.25e-3,"DisplayType","texturemap");
follow the documentation below for reference: geoshow
Catégories
En savoir plus sur Vector and Raster Map Display dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

