Axis Labels/Tick Marks for surfm plot

조회 수: 9 (최근 30일)
Evan Kutta
Evan Kutta 2015년 8월 22일
편집: dpb 2015년 8월 24일
Here is my working code to generate a 4 panel plot of northern hemisphere seasonal wind speeds with a map in the background using Matlab 2015a:
lat = linspace(0, 90, size(Vwin,1));
lon = linspace(-180, 180, size(Vwin,2));
data = {Vwin, Vspr, Vsum, Vfal};
Title = {'\fontsize{23} \bf NHFT Mean Merid Winter Wind Speed';
'\fontsize{23} \bf NHFT Mean Merid Spring Wind Speed';
'\fontsize{23} \bf NHFT Mean Merid Summer Wind Speed';
'\fontsize{23} \bf NHFT Mean Merid Fall Wind Speed'};
coast = load('coast');
figure;
for ii = 1:4
ax(ii) = axes('position', pos(ii,:));
axesm('eqdcylin','origin',[0 270 0],'MapLatLimit',[0 90]);
gridm on;
surfm(lat, lon, data{ii},'EdgeColor','none'); colormap(jet);
caxis([-8,8]); set(gca,'FontSize',17);
geoshow(coast, 'color', 'k');
tightmap;
title(Title{ii});
xlabel('\fontsize{20} \bf Longitude');
ylabel('\fontsize{20} \bf Latitude');
end
Here is what I had used previously to define grid axis ticks and labels of a surf plot:
set(gca,'xlim',[1 180]); set(gca,'XTick',(1:10:180)); set(gca,'XtickLabel',(-180:20:180));
set(gca,'ylim',[1 46]); set(gca,'YTick',(1:5:46)); set(gca,'YtickLabel',(0:10:90));
When I plug this directly into the loop, it labels the axes correctly but doesn't show the data or map correctly. Alternatively, using setm(gca ....) gives me the error below. Thus, I am unsure how to properly assign axis ticks or labels to a surfm plot.
Error using setm>verifyAxesChildren (line 399)
There is data in an hggroup that cannot be reprojected.
Error in setmasetmaxes (line 111)
verifyAxesChildren(ax, oldstruct, varargin{:});
Error in setm (line 49)
setmaxes(varargin{:});
Error in Map (line 40)
setm(gca,'xlim',[1 180]); set(gca,'XTick',(1:10:180)); set(gca,'XtickLabel',(-180:20:180));
Thank you very much, Evan Kutta
  댓글 수: 1
Evan Kutta
Evan Kutta 2015년 8월 22일
I have a feeling this page in the documentation might have the answer, but I am not exactly sure. Accessing and Manipulating Map Axes Properties

댓글을 달려면 로그인하십시오.

채택된 답변

Evan Kutta
Evan Kutta 2015년 8월 24일
I figured out my limits above went well beyond the boundaries of the map, here is what I used to label my northern hemisphere plot axes tick marks.
set(gca,'xlim',[-2.7 2.7],'XTick',(-2.7:.45:2.7)); set(gca,'XtickLabel',(-90:30:270));
set(gca,'ylim',[0 1.6],'YTick',(0:.25:3),'YtickLabel',(0:15:90));
  댓글 수: 1
dpb
dpb 2015년 8월 24일
편집: dpb 2015년 8월 24일
While again I don't have the Mapping Toolbox to investigate/experiment with, there's likely a reason for the following note in the doc's--
"Map axes are standard MATLAB axes with different default settings for some properties and a MATLAB structure for storing projection parameters and other data. The main differences in default settings are." "Axes properties XGrid, YGrid, XTick, YTick are set to 'off'."
Have you tried the alternate properties
MLineLimit
[north south] | [south north] {[]}
Grid meridian limits — ...
MLineLocation
scalar interval or specific vector {30º}
Grid meridian interval or specific locations — ...
and the analogous Pxxxx versions for parallels?
No idea what may/may not function correctly with the underlying grid but seems only prudent to use the tools as intended...

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

dpb
dpb 2015년 8월 23일
I don't have the Toolbox so can't 'spearmint but it appears from your link there is no 'x|ytick' property for the specific object but following thru the maze from setm documents to the properties pages leads you (eventually) to http://www.mathworks.com/help/map/ref/axesm.html#f12-65627 which looks like they're called 'M|PLineXXXX' properties for meridian and parallel axes, respectively.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by