Wednesday, April 20, 2016

Matlab Plot Latitude and Longitude with degree symbol on the axis label

Not the complete code, but it does the job.
close all
load coast
cfigure( 40, 20);
plot(long, lat, 'k')
grid on
% s = sprintf('45%c', char(176));

set(gca,'XLim',[-180 180])
set(gca,'YLim',[-180/2 180/2])
set(gca,'XTick',[-180:40: 180])
set(gca,'YTick',[-90:30: 90])

xt=get(gca,'xtick');
for k=1:numel(xt);
xt1{k}=sprintf('%d°',xt(k));
end
set(gca,'xticklabel',xt1);

xt=get(gca,'ytick');
for k=1:numel(xt);
xt1{k}=sprintf('%d°',xt(k));
end
set(gca,'yticklabel',xt1);

set(gca,'Fontsize',26)

annotation('textbox', [.15  .232 0.16  0.1 ],'EdgeColor',[ 0 0 0] )

% xlim([-180 180])
% ylim([-90 90])
hold on
plot(longitude(dayyes==0), latitude(dayyes==0), 'o', 'MarkerEdgeColor','b','MarkerSize',5);
plot(longitude(dayyes==1),latitude(dayyes==1), '*', 'MarkerEdgeColor','r','MarkerSize',6);
text(-167,-50,  sprintf('* Day Profile  ' ), 'color', 'r', 'FontSize', 26)
text(-167,-60,  sprintf('o Night Profile' ), 'color', 'b', 'FontSize', 26)
%    annotation('textbox', [-175  -55 20  15 ],'EdgeColor',[0 0 0] )
ylabel('Latitude ', 'FontSize', 26)
xlabel('Longitude ', 'FontSize', 26)
set(gcf,'Color','white')

No comments: