Issues with Contour fill when using GRD datasets
Hi,
I’m attempting to use the GRDread2 function (grdread2 – File Exchange – MATLAB Central (mathworks.com)) to read in and then display as filled contour maps (code below).
%%%%%%%% Generate Data
load coastlines
[X,Y,Z] = grdread2(‘SD01.zmax.grd’);
grdinfo2(‘SD01.zmax.grd’);
%%%%%%%% Generate Data
hfig1 = figure % creates a graph
FW = 60; % scaling factor
set(hfig1, ‘Position’, [000 000 16 9]*FW) % sets scaling of figure [left bottom width height]
ax(1) = axes(‘position’,[0.12 0.12 0.4 0.85]) % creates an axis [left bottom width height]
hold on; box on; grid on;
set(gca,’layer’,’top’) % get current axis set frame to top
contourf(X,Y,Z,10)
ch1 = colorbar
set(ax(1),’Colormap’,jet(20))
caxis([-6 8])
ax(2) = axes(‘position’,[0.57 0.12 0.4 0.85])
hold on; box on; grid on;
set(gca,’layer’,’top’)
contourf(X,Y,Z)
contour(X,Y,Z,-1:0.5:10,’k-‘)
ch2 = colorbar;
caxis([-1 10])
cmap2 = cmocean(‘balance’);
set(ax(2),’Colormap’,cmap2)
However, while checking the output shows that the Z elevation data is present (and can be plotted with contour lines) the image only displays two colour bands (image attached). I’m relatively new to Matlab and was wondering what I’ve missed?
Many thanks,Hi,
I’m attempting to use the GRDread2 function (grdread2 – File Exchange – MATLAB Central (mathworks.com)) to read in and then display as filled contour maps (code below).
%%%%%%%% Generate Data
load coastlines
[X,Y,Z] = grdread2(‘SD01.zmax.grd’);
grdinfo2(‘SD01.zmax.grd’);
%%%%%%%% Generate Data
hfig1 = figure % creates a graph
FW = 60; % scaling factor
set(hfig1, ‘Position’, [000 000 16 9]*FW) % sets scaling of figure [left bottom width height]
ax(1) = axes(‘position’,[0.12 0.12 0.4 0.85]) % creates an axis [left bottom width height]
hold on; box on; grid on;
set(gca,’layer’,’top’) % get current axis set frame to top
contourf(X,Y,Z,10)
ch1 = colorbar
set(ax(1),’Colormap’,jet(20))
caxis([-6 8])
ax(2) = axes(‘position’,[0.57 0.12 0.4 0.85])
hold on; box on; grid on;
set(gca,’layer’,’top’)
contourf(X,Y,Z)
contour(X,Y,Z,-1:0.5:10,’k-‘)
ch2 = colorbar;
caxis([-1 10])
cmap2 = cmocean(‘balance’);
set(ax(2),’Colormap’,cmap2)
However, while checking the output shows that the Z elevation data is present (and can be plotted with contour lines) the image only displays two colour bands (image attached). I’m relatively new to Matlab and was wondering what I’ve missed?
Many thanks, Hi,
I’m attempting to use the GRDread2 function (grdread2 – File Exchange – MATLAB Central (mathworks.com)) to read in and then display as filled contour maps (code below).
%%%%%%%% Generate Data
load coastlines
[X,Y,Z] = grdread2(‘SD01.zmax.grd’);
grdinfo2(‘SD01.zmax.grd’);
%%%%%%%% Generate Data
hfig1 = figure % creates a graph
FW = 60; % scaling factor
set(hfig1, ‘Position’, [000 000 16 9]*FW) % sets scaling of figure [left bottom width height]
ax(1) = axes(‘position’,[0.12 0.12 0.4 0.85]) % creates an axis [left bottom width height]
hold on; box on; grid on;
set(gca,’layer’,’top’) % get current axis set frame to top
contourf(X,Y,Z,10)
ch1 = colorbar
set(ax(1),’Colormap’,jet(20))
caxis([-6 8])
ax(2) = axes(‘position’,[0.57 0.12 0.4 0.85])
hold on; box on; grid on;
set(gca,’layer’,’top’)
contourf(X,Y,Z)
contour(X,Y,Z,-1:0.5:10,’k-‘)
ch2 = colorbar;
caxis([-1 10])
cmap2 = cmocean(‘balance’);
set(ax(2),’Colormap’,cmap2)
However, while checking the output shows that the Z elevation data is present (and can be plotted with contour lines) the image only displays two colour bands (image attached). I’m relatively new to Matlab and was wondering what I’ve missed?
Many thanks, grd, contour MATLAB Answers — New Questions