Why are there missing pixels in my "heat map" plot using pcolorm?
Mostra commenti meno recenti
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 Commenti
Mark Brandon
il 4 Nov 2022
Spostato: Star Strider
il 4 Nov 2022
Mark Brandon
il 5 Nov 2022
Modificato: Mark Brandon
il 5 Nov 2022
Andrew Stevens
il 12 Ott 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
il 12 Ott 2023
Risposte (2)
Suvansh Arora
il 8 Nov 2022
0 voti
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 Commenti
Mark Brandon
il 8 Nov 2022
Suvansh Arora
il 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
il 9 Nov 2022
Suvansh Arora
il 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
il 11 Nov 2022
0 voti
2 Commenti
Suvansh Arora
il 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
il 21 Dic 2022
Modificato: Suvansh Arora
il 21 Dic 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
Categorie
Scopri di più su Measurements and Spatial Audio in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

