![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/202680/image.png)
How to fix black figure error?
20 views (last 30 days)
Show older comments
Keegan Carvalho
on 4 Feb 2019
Commented: Star Strider
on 5 Feb 2019
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/202675/image.jpeg)
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 Comments
Accepted Answer
Star Strider
on 4 Feb 2019
Edited: Star Strider
on 4 Feb 2019
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/202680/image.png)
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 Comments
Star Strider
on 5 Feb 2019
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.
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.
0 Comments
See Also
Categories
Find more on Red 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!