Why are there missing pixels in my "heat map" plot using pcolorm?
Mostrar comentarios más antiguos
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 comentarios
Mark Brandon
el 4 de Nov. de 2022
Movida: Star Strider
el 4 de Nov. de 2022
Mark Brandon
el 5 de Nov. de 2022
Editada: Mark Brandon
el 5 de Nov. de 2022
Andrew Stevens
el 12 de Oct. de 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
el 12 de Oct. de 2023
Respuestas (2)
Suvansh Arora
el 8 de Nov. de 2022
0 votos
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 comentarios
Mark Brandon
el 8 de Nov. de 2022
Suvansh Arora
el 9 de Nov. de 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
el 9 de Nov. de 2022
Suvansh Arora
el 11 de Nov. de 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
el 11 de Nov. de 2022
0 votos
2 comentarios
Suvansh Arora
el 23 de Nov. de 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
el 21 de Dic. de 2022
Editada: Suvansh Arora
el 21 de Dic. de 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
Categorías
Más información sobre Vector and Raster Map Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

