MATLAB: Geoshow polar plot rotation needs activation via set(gca, ‘CameraViewAngleMode’, ‘manual’) but that shrinks the plot an (afaik) arbitrary amount – how to get around this

geoshowMapping Toolboxpolarrotate

Below is code that shows the effect. If I do not call set(gca, 'CameraViewAngleMode', 'manual') the polar plot will shrink based on rotation angle and is really useless. If I call set(gca, 'CameraViewAngleMode', 'manual') it shrinks geoshow – I managed to maneuver the call for the initial geoshow to not resize but can't manage it for the second.
Unfortunately, I cannot use the both resized result as I plot on this with regular plot commands like pcolor and plot – they are not resized and re-aligning things is egregiously difficult. I also need multiple axes unfortunately, and geoshow wasn't showing up at all calling on just the original axis.
Does anyone have insight into this peculiar behavior? Seems heavy.
Thanks.
Additionally, a 3rd case where geoshow is replaced with plot is included. The lat/long is converted to X/Y from 0 to the first plot's axis limit linearly, with poor result. There's some weird projection thing going on (the direct plot matches with the resized near the poles and then matches with the full-sized near the edges). Maybe can give some insight into underlying issue since it all seems related? Would be good to understand it too (for plot accuracy).
A lot of code follows. Don't know how to minimize it and pastebin might put off people (?).
Code included makes 4 plots:
1. First (main) plot is not resized but second (line-only) plot is.
2. Both plots are resized.
3+4. First (main) plot is not resized and second plot has geoshow replaced with plot (with lat/long converted to X/Y from 0 to first plot's axis limit). 4 has the first (main) plot resized.
coastLines = load('coast');%loads coast line into structure, vars are lat and long - can interfere with previous code so hidden in structure
coastLines_lat = coastLines.lat; %breaks this data out
coastLines_long = coastLines.long;
%********** ONLY SECOND RESIZED ***********
fig1 = figure('Color','w','units','normalized','outerposition',[0 0 1 1]); %maximizes figure window, makes it white



fig1Axes = axes('Parent', fig1); %gets a reference to the axes for later



axesm('eqaazim','MLabelParallel',0,'Origin',[90,0,0],'MapLatLimit',[35 , 90]);
axis off
framem on
gridm on
mlabel on
plabel on;
setm(gca,'MLabelParallel',0,'FFaceColor', [.5 .7 .9]); %FFaceColor sets ocean color



hMap = geoshow(fig1Axes,coastLines_lat,coastLines_long,'DisplayType','polygon','FaceColor', [0.5 0.7 0.5]);
axis equal tight %key for plotScaleFactor





% key for spinning the plot



title('1 Main plot orig size, second line-only plot resized'); %fire up the title



fig1Title = get(fig1Axes,'Title'); % handle of title, need it for later b/c rotation moves title location



set(gca, 'fontweight','bold', 'FontSize',18);
hold on;
plotScaleFactor = max(xlim); %record, plot scale factor (it goes from 0 to a # less than 1)



defaultTitlePosition = get(fig1Title,'Position') + [0 , 0.04, 0]; %Set the default title position



set(fig1Title,'Position',defaultTitlePosition); % Shift the position upward



defaultTitlePosition_Mag = norm(defaultTitlePosition); %get mag of the default title position for rotation calcs



fig1Axes_pos = get(fig1Axes,'Position');
set(gca, 'CameraViewAngleMode', 'manual'); % 'CameraTargetMode', 'manual', 'CameraPositionMode', 'manual' extra calls that aren't needed for what I want



%Put at end avoids resize
disp('1 Only Second Resized Run - 1st plot reported position:');
get(fig1Axes,'Position')
%Make sure coastal lines are visible
axOverlay = axes('Parent', fig1); %create independent axes for the two plots (TEC and AMPERE)



linkaxes([fig1Axes,axOverlay]); %link em



set(axOverlay,'CameraViewAngleMode', 'manual'); %do this after so it doesn't have the resize bug

axesm('eqaazim','MLabelParallel',0,'Origin',[90,0,0],'MapLatLimit',[35 , 90]);
axis off
framem on
gridm on
mlabel on
plabel on;
hOverlay = geoshow(axOverlay,coastLines_lat,coastLines_long,'Color','k'); %add continental outlines in black



axis equal tight %key for plotScaleFactor
% axOverlay.Position = fig1Axes_pos.*[.918,.9,1.028,1.027]; %manually-found points to align to circular grid size

hold on;
disp('1 Only Second Resized Run - 2nd plot reported position:');
get(axOverlay,'Position')
%ROTATE



angle = 35*pi/180; %deg



set(fig1Axes,'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angle







set(axOverlay, 'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angle
rotatedTitlePosition = [defaultTitlePosition_Mag*cos(angle) , defaultTitlePosition_Mag*sin(angle) , 0]; %calc new top once the plot has been rotated



set(fig1Title,'Position',rotatedTitlePosition); %Apply the new top position so title stays where it should



%************* BOTH RESIZED ******************
fig1 = figure('Color','w','units','normalized','outerposition',[0 0 1 1]); %maximizes figure window, makes it white
fig1Axes = axes('Parent', fig1); %gets a reference to the axes for later
set(fig1Axes, 'CameraViewAngleMode', 'manual'); % 'CameraTargetMode', 'manual', 'CameraPositionMode', 'manual' extra calls that aren't needed for what I want
%Placed here, it resizes
axesm('eqaazim','MLabelParallel',0,'Origin',[90,0,0],'MapLatLimit',[35 , 90]);
axis off
framem on
gridm on
mlabel on
plabel on;
setm(gca,'MLabelParallel',0,'FFaceColor', [.5 .7 .9]); %FFaceColor sets ocean color
hMap = geoshow(fig1Axes,coastLines_lat,coastLines_long,'DisplayType','polygon','FaceColor', [0.5 0.7 0.5]);
axis equal tight %key for plotScaleFactor
% key for spinning the plot
title('2 Both plots resized'); %fire up the title
fig1Title = get(fig1Axes,'Title'); % handle of title, need it for later b/c rotation moves title location
set(gca, 'fontweight','bold', 'FontSize',18);
hold on;
plotScaleFactor = max(xlim); %record, plot scale factor (it goes from 0 to a # less than 1)
defaultTitlePosition = get(fig1Title,'Position') + [0 , 0.04, 0]; %Set the default title position
set(fig1Title,'Position',defaultTitlePosition); % Shift the position upward
defaultTitlePosition_Mag = norm(defaultTitlePosition); %get mag of the default title position for rotation calcs
fig1Axes_pos = get(fig1Axes,'Position');
disp('2 Both Resized Run - 1st plot reported position:');
get(fig1Axes,'Position')
%ake sure coastal lines are visible
axOverlay = axes('Parent', fig1); %create independent axes for the two plots (TEC and AMPERE)
linkaxes([fig1Axes,axOverlay]); %link em
set(axOverlay,'CameraViewAngleMode', 'manual'); %do this after so it doesn't have the resize bug
axesm('eqaazim','MLabelParallel',0,'Origin',[90,0,0],'MapLatLimit',[35 , 90]);
axis off
framem on
gridm on
mlabel on
plabel on;
hOverlay = geoshow(axOverlay,coastLines_lat,coastLines_long,'Color','k'); %add continental outlines in black
axis equal tight %key for plotScaleFactor
% axOverlay.Position = fig1Axes_pos.*[.918,.9,1.028,1.027]; %manually-found points to align to circular grid size
hold on;
disp('2 Both Resized Run - 2nd plot reported position:');
get(axOverlay,'Position')
%ROTATE
angle = 35*pi/180; %deg
set(fig1Axes,'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angle
set(axOverlay, 'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angle
rotatedTitlePosition = [defaultTitlePosition_Mag*cos(angle) , defaultTitlePosition_Mag*sin(angle) , 0]; %calc new top once the plot has been rotated
set(fig1Title,'Position',rotatedTitlePosition); %Apply the new top position so title stays where it should
%***********TRY WITHOUT 2ND GEOSHOW*****************
fig1 = figure('Color','w','units','normalized','outerposition',[0 0 1 1]); %maximizes figure window, makes it white
fig1Axes = axes('Parent', fig1); %gets a reference to the axes for later
axesm('eqaazim','MLabelParallel',0,'Origin',[90,0,0],'MapLatLimit',[35 , 90]);
axis off
framem on
gridm on
mlabel on
plabel on;
setm(gca,'MLabelParallel',0,'FFaceColor', [.5 .7 .9]); %FFaceColor sets ocean color
hMap = geoshow(fig1Axes,coastLines_lat,coastLines_long,'DisplayType','polygon','FaceColor', [0.5 0.7 0.5]);
axis equal tight %key for plotScaleFactor
% key for spinning the plot
title('3 No Geoshow, No Resize - But Plot Can''t Line (heh) Up'); %fire up the title
fig1Title = get(fig1Axes,'Title'); % handle of title, need it for later b/c rotation moves title location
set(gca, 'fontweight','bold', 'FontSize',18);
hold on;
plotScaleFactor = max(xlim); %record, plot scale factor (it goes from 0 to a # less than 1)
defaultTitlePosition = get(fig1Title,'Position') + [0 , 0.04, 0]; %Set the default title position
set(fig1Title,'Position',defaultTitlePosition); % Shift the position upward
defaultTitlePosition_Mag = norm(defaultTitlePosition); %get mag of the default title position for rotation calcs
fig1Axes_pos = get(fig1Axes,'Position');
set(gca, 'CameraViewAngleMode', 'manual'); % 'CameraTargetMode', 'manual', 'CameraPositionMode', 'manual' extra calls that aren't needed for what I want
%no resize here
disp('3 No 2nd Geoshow Run - 1st plot reported position:');
get(fig1Axes,'Position')
coastLines_lat_Circ = ((((90-coastLines_lat))/(90-35)).*plotScaleFactor ).*sind(coastLines_long-90); %0 to 1, create Y points circular coords

coastLines_long_Circ = ((((90-coastLines_lat))/(90-35)).*plotScaleFactor ).*cosd(coastLines_long-90); %0 to 1, create X points circular coords

k = sqrt( (coastLines_lat_Circ).^2 + (coastLines_long_Circ).^2 ) > plotScaleFactor; %coastLines conversion allows for regular plot to be used b/c GEOSHOW

coastLines_lat_Circ(k) = []; %delete



coastLines_long_Circ(k) = []; %delete
axOverlay = axes('Parent', fig1); %create independent axes for the two plots (TEC and AMPERE)
linkaxes([fig1Axes,axOverlay]); %link em
hOverlay = plot(axOverlay,coastLines_long_Circ,coastLines_lat_Circ,'Color','k'); %add continental outlines in black
axOverlay.Visible = 'off'; %hide the 2nd axes set





axOverlay.XTick = []; %hide the 2nd axes set
axOverlay.YTick = []; %hide the 2nd axes set
pbaspect(axOverlay,[1 1 1])
xlim(axOverlay,[-plotScaleFactor, plotScaleFactor]); %force axis to be this



ylim(axOverlay,[-plotScaleFactor, plotScaleFactor]); %force axis to be this
set(axOverlay, 'CameraViewAngleMode', 'manual');
hold on;
disp('3 No 2nd Geoshow Run - 2nd plot reported position:');
get(axOverlay,'Position')
%ROTATE
angle = 35*pi/180; %deg
set(fig1Axes,'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angle
set(axOverlay, 'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angle
rotatedTitlePosition = [defaultTitlePosition_Mag*cos(angle) , defaultTitlePosition_Mag*sin(angle) , 0]; %calc new top once the plot has been rotated
set(fig1Title,'Position',rotatedTitlePosition); %Apply the new top position so title stays where it should
%***********TRY WITHOUT 2ND GEOSHOW BUT WITH FIRST RESIZE*****************
fig1 = figure('Color','w','units','normalized','outerposition',[0 0 1 1]); %maximizes figure window, makes it white
fig1Axes = axes('Parent', fig1); %gets a reference to the axes for later
set(gca, 'CameraViewAngleMode', 'manual'); % 'CameraTargetMode', 'manual', 'CameraPositionMode', 'manual' extra calls that aren't needed for what I want
%resize here
axesm('eqaazim','MLabelParallel',0,'Origin',[90,0,0],'MapLatLimit',[35 , 90]);
axis off
framem on
gridm on
mlabel on
plabel on;
setm(gca,'MLabelParallel',0,'FFaceColor', [.5 .7 .9]); %FFaceColor sets ocean color
hMap = geoshow(fig1Axes,coastLines_lat,coastLines_long,'DisplayType','polygon','FaceColor', [0.5 0.7 0.5]);
axis equal tight %key for plotScaleFactor
% key for spinning the plot
title('4 No Geoshow, But with Resize - But Plot Can''t Line (heh) Up'); %fire up the title
fig1Title = get(fig1Axes,'Title'); % handle of title, need it for later b/c rotation moves title location
set(gca, 'fontweight','bold', 'FontSize',18);
hold on;
plotScaleFactor = max(xlim); %record, plot scale factor (it goes from 0 to a # less than 1)
defaultTitlePosition = get(fig1Title,'Position') + [0 , 0.04, 0]; %Set the default title position
set(fig1Title,'Position',defaultTitlePosition); % Shift the position upward
defaultTitlePosition_Mag = norm(defaultTitlePosition); %get mag of the default title position for rotation calcs
fig1Axes_pos = get(fig1Axes,'Position');
disp('4 No 2nd Geoshow Run - 1st plot reported position:');
get(fig1Axes,'Position')
coastLines_lat_Circ = ((((90-coastLines_lat))/(90-35)).*plotScaleFactor ).*sind(coastLines_long-90); %0 to 1, create Y points circular coords
coastLines_long_Circ = ((((90-coastLines_lat))/(90-35)).*plotScaleFactor ).*cosd(coastLines_long-90); %0 to 1, create X points circular coords
k = sqrt( (coastLines_lat_Circ).^2 + (coastLines_long_Circ).^2 ) > plotScaleFactor; %coastLines conversion allows for regular plot to be used b/c GEOSHOW
coastLines_lat_Circ(k) = []; %delete
coastLines_long_Circ(k) = []; %delete
axOverlay = axes('Parent', fig1); %create independent axes for the two plots (TEC and AMPERE)
linkaxes([fig1Axes,axOverlay]); %link em
hOverlay = plot(axOverlay,coastLines_long_Circ,coastLines_lat_Circ,'Color','k'); %add continental outlines in black
axOverlay.Visible = 'off'; %hide the 2nd axes set
axOverlay.XTick = []; %hide the 2nd axes set
axOverlay.YTick = []; %hide the 2nd axes set
pbaspect(axOverlay,[1 1 1])
xlim(axOverlay,[-plotScaleFactor, plotScaleFactor]); %force axis to be this
ylim(axOverlay,[-plotScaleFactor, plotScaleFactor]); %force axis to be this
set(axOverlay, 'CameraViewAngleMode', 'manual');
hold on;
disp('4 No 2nd Geoshow Run - 2nd plot reported position:');
get(axOverlay,'Position')
%ROTATE
angle = 35*pi/180; %deg
set(fig1Axes,'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angle
set(axOverlay, 'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angle
rotatedTitlePosition = [defaultTitlePosition_Mag*cos(angle) , defaultTitlePosition_Mag*sin(angle) , 0]; %calc new top once the plot has been rotated
set(fig1Title,'Position',rotatedTitlePosition); %Apply the new top position so title stays where it should

Best Answer

Update: Using worldmap to initialize the axes and cutting off the command axesm('equazim'...) is a work around, I've found.
The worldmap call makes a polar plot by default for my limits (if it doesn't getm(gca) seems to give a lot of info on what can be adjusted maybe that provides a way...) and it works on an arclength distance from the origin at the pole which is (0,0).
Edit: setm(gca,'mapprojection','eqdazim'); should force polar plot since that's what mine is set to.
The code to make the first plot that doesn't shrink with camera rotation is below (second, long). Some extra bits in gridm were needed to apply basic stuff that axesm('eqaazim') seemed to do - like turning off label rotation. Otherwise it works well and lat/long can be projected on with an arclength formula (below first).
Work around found - but no solution to the weird shrinking plots.
ReAdj = Re*1000*pi/180; %convert Re to meters, toss in the pi/180 conversion needed for degrees as well
coastLines_lat_Circ = (max(plotLatRange)-coastLines_lat).*ReAdj.*sind(coastLines_long-90); %create Y points circular coords
coastLines_long_Circ = (max(plotLatRange)-coastLines_lat).*ReAdj.*cosd(coastLines_long-90); %create X points circular coords
%CREATE THE FIGURE WE WILL USE
fig1 = figure('Color','w','units','normalized','outerposition',[0 0 1 1]); %maximizes figure window, makes it white
fig1Axes = worldmap([min(plotLatRange) , max(plotLatRange)],[min(plotLongRange) , max(plotLongRange)]); %tries to standardize the maps
% fig1Axes = axes('Parent', fig1); %gets a reference to the axes for later
% axesm('eqaazim','MLabelParallel',0,'Origin',gif_OriginCentering,'MapLatLimit',[min(plotLatRange) , max(plotLatRange)]); %ruins it
axis off
framem on
gridm on
mlabel on
plabel on; %
setm(gca,'MLabelParallel',0,'FFaceColor', [176/255,196/255,222/255]); %FFaceColor sets ocean color (orig color [.5,.7,.9]) powder blue: [176/255,224/255,230/255]
hMap = geoshow(fig1Axes,coastLines_lat,coastLines_long,'DisplayType','polygon','FaceColor', [0.5 0.7 0.5]);
axis equal tight %key for plotScaleFactor (adjusts size slightly...)
gridm('k'); %set grid dotted lines color to black (was sea color..)
gridm('plinelocation',15,'plabellocation',15,'labelrotation','off'); %force latitude numbers each 15 deg
%key for spinning the plot
title('Prep Title'); %fire up the title
fig1Title = get(fig1Axes,'Title'); % handle of title, need it for later b/c rotation moves title location
set(gca, 'fontweight','bold', 'FontSize',18);
hold on;
plotScaleFactor = max(xlim); %record, plot scale factor (it goes from 0 to a # less than 1)
defaultTitlePosition = get(fig1Title,'Position') + [0 , 0.30*(10^(length(num2str(round(plotScaleFactor)))-1)), 0]; %Set the default title position
set(fig1Title,'Position',defaultTitlePosition); % Shift the position upward
defaultTitlePosition_Mag = norm(defaultTitlePosition); %get mag of the default title position for rotation calcs
fig1Axes_pos = get(fig1Axes,'Position');
%PUT THIS CALL AT END SO WEIRD SIZING DOESN'T HAPPEN - way annoying
set(gca, 'CameraViewAngleMode', 'manual'); % 'CameraTargetMode', 'manual', 'CameraPositionMode', 'manual' extra calls that aren't needed for what I want
%NOTE: Typing gca gets you a ton of deets on the plot's settings