How to fix black figure error?
Show older comments
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.
Accepted Answer
More Answers (1)
Steven Lord
on 4 Feb 2019
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.
Categories
Find more on NetCDF in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!