Why are there missing pixels in my "heat map" plot using pcolorm?
이전 댓글 표시
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
Mark Brandon
2022년 11월 4일
이동: Star Strider
2022년 11월 4일
Mark Brandon
2022년 11월 5일
편집: Mark Brandon
2022년 11월 5일
Andrew Stevens
2023년 10월 12일
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
2023년 10월 12일
답변 (2개)
Suvansh Arora
2022년 11월 8일
0 개 추천
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
Mark Brandon
2022년 11월 8일
Suvansh Arora
2022년 11월 9일
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
2022년 11월 9일
Suvansh Arora
2022년 11월 11일
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
2022년 11월 11일
0 개 추천
댓글 수: 2
Suvansh Arora
2022년 11월 23일
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
2022년 12월 21일
편집: Suvansh Arora
2022년 12월 21일
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
카테고리
도움말 센터 및 File Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

