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!

