How to fix black figure error?

16 visualizaciones (últimos 30 días)
Keegan Carvalho
Keegan Carvalho el 4 de Feb. de 2019
Comentada: Star Strider el 5 de Feb. de 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
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.

Respuesta aceptada

Star Strider
Star Strider el 4 de Feb. de 2019
Editada: Star Strider el 4 de Feb. de 2019
Use the image (link) function instead. It will give you:
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 comentarios
Keegan Carvalho
Keegan Carvalho el 5 de Feb. de 2019
Editada: Keegan Carvalho el 5 de Feb. de 2019
Star Strider, I've tried the image function and it has worked. But the temperatures values (colorbar) are wrong. The temperature values range from 250K and above.
However, you mentioned that the data sizes are not appropriate; could you tell me what it means?
My data contains latitudes from 70-90N and 0-360E and I am mapping the Arctic Ocean.
Star Strider
Star Strider el 5 de Feb. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

Steven Lord
Steven Lord el 4 de Feb. de 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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by