How to fix black figure error?
16 次查看(过去 30 天)
显示 更早的评论
I have attached a zipped netcdf file named 'trial'. I wanted to plot a variable 'sst' on the map; the data is downloaded for the arctic ocean i.e. 70-90N and 0-360E.
However I am getting a black figure when tyring to plot the average of 'sst' variable. I have used the following code and get the image (attached).
lon=ncread('trial.nc','longitude');
lat=ncread('trial.nc','latitude');
sst=ncread('trial.nc','sst');
iwant=mean(sst,3);
pcolor(lon,lat,iwant')
colorbar
drawnow
I would like some assistance in the matter of the black figure.
I believe the above map is created based on the cartesian coordiantes. Would be grateful to receive some help in creating a polar map.
0 个评论
采纳的回答
Star Strider
2019-2-4
编辑:Star Strider
2019-2-4
There are other options as well, such as surf, mesh, and contourf. The Mapping Toolbox (that I don’t have) may also have functions that could be more appropriate.
EDIT —
Your data sizes are not appropriate with respect to converting them to Cartesian ⇔ polar coordinates. Search the Mapping Toolbox for an appropriate function.
2 个评论
Star Strider
2019-2-5
The ‘data size’ referred to my attempting to convert it to polar coordinates using pol2cart. Since it appears to be centred around 90°S, I thought that might work, since I have used a similar approach in other plotting problems. (Perhaps I simply do not understand your data.)
I would also see if the contourf function will work with your data. You can set the number of contours, and tweak it to do what you want.
更多回答(1 个)
Steven Lord
2019-2-4
You have a lot of individual squares in the "checkerboard" being displayed. What you're seeing are all the edges between the squares. If you change the color of the edges to 'none' you'll be able to see the underlying data. First view some sample data with the edges. You won't be able to see the underlying surface.
z = peaks(1000);
h = pcolor(z); % All black
Now turn off the edge color so you can see the details of the peaks surface data.
h.EdgeColor = 'none'; % Colorful
Alternately you might want to use the shading function to change the shading from the default 'faceted' to 'flat' or 'interp'. Not only will this have an effect on the edges but it will also affect how the color of each cell is selected. See the documentation page for pcolor and shading for more information.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Map Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!