Hello all,
I have asked a similar question before, but have yet to find/create a satisfactory solution. I am attempting to plot position data that comes in latitude-longitude. These are over a relatively small area, so there is a direct conversion from lat/lon into meters N/E relative to some reference point. I am attempting to plot the data with the meters-E and meters-N on the x and y axes respectively. I want a second pair of xx and yy axes on the top and right side respectively plotting the latitude and longitude. This I have managed to do. The sticking point is that I want to lock the figure to equal axes in x-y direction in meters so that the data has a realistic aspect ratio. This then kills the second pair of axes. Two sample image, and then some pseudo-code below:
Here we can see what I am going for with two major problems: the y-tick labels are cut-off on the right side, and the x-y axes are squished.
Now, I use axis equal on the first axes (the one in meters). This actually has the correct aspect ratio, but you can see that the second axies has not remained locked with the first. This is bad.
This whole process is really kludgey. The closest I got was to add a pbaspect command to the second axes and I get. It is still definitely not correct. 
I am simply floored that there isn't really a way to have multiple axes for the same data. I will attach a gross code example below, and hope that someone has a suggestion. The core technique was suggested in this Mathworks page.
lat0 = 51.2697;
lon0 = -77.3379;
dLat = 1.5696e-07;
dLon = 2.5087e-07;
dx = rand(100,1);
dy = rand(100,1);
x = cumsum(dx);
y = cumsum(dy);
lat = 360/(2*pi)*y*dLat + lat0;
lon = 360/(2*pi)*x*dLon + lon0;
close all
figure();
plot(x,y,'b.');
xlabel('Easting (m)');
ylabel('Northing (m)');
set(gca,'box','off')
axis equal; axis tight;
ax1 = gca;
ax1_pos = ax1.Position;
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
xt = xticks;
yt = yticks;
xticks(xt(1:3:end));
yticks(yt(1:3:end));
xt = xticks;
yt = yticks;
latL = linspace(min(lat),max(lat),length(xt));
lonL = linspace(min(lon),max(lon),length(yt));
xticklabels(lonL);
yticklabels(latL);
pbaspect([dLat/dLon,1,1]);
0 件のコメント
サインインしてコメントする。