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 offframem ongridm onmlabel onplabel 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 offframem ongridm onmlabel onplabel 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 anglerotatedTitlePosition = [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 whitefig1Axes = axes('Parent', fig1); %gets a reference to the axes for laterset(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 offframem ongridm onmlabel onplabel on;setm(gca,'MLabelParallel',0,'FFaceColor', [.5 .7 .9]); %FFaceColor sets ocean colorhMap = 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 plottitle('2 Both plots resized'); %fire up the titlefig1Title = get(fig1Axes,'Title'); % handle of title, need it for later b/c rotation moves title locationset(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 positionset(fig1Title,'Position',defaultTitlePosition); % Shift the position upwarddefaultTitlePosition_Mag = norm(defaultTitlePosition); %get mag of the default title position for rotation calcsfig1Axes_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 emset(axOverlay,'CameraViewAngleMode', 'manual'); %do this after so it doesn't have the resize bugaxesm('eqaazim','MLabelParallel',0,'Origin',[90,0,0],'MapLatLimit',[35 , 90]);axis offframem ongridm onmlabel onplabel 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 sizehold on;disp('2 Both Resized Run - 2nd plot reported position:');get(axOverlay,'Position')%ROTATEangle = 35*pi/180; %degset(fig1Axes,'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angleset(axOverlay, 'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an anglerotatedTitlePosition = [defaultTitlePosition_Mag*cos(angle) , defaultTitlePosition_Mag*sin(angle) , 0]; %calc new top once the plot has been rotatedset(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 whitefig1Axes = axes('Parent', fig1); %gets a reference to the axes for lateraxesm('eqaazim','MLabelParallel',0,'Origin',[90,0,0],'MapLatLimit',[35 , 90]);axis offframem ongridm onmlabel onplabel on;setm(gca,'MLabelParallel',0,'FFaceColor', [.5 .7 .9]); %FFaceColor sets ocean colorhMap = 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 plottitle('3 No Geoshow, No Resize - But Plot Can''t Line (heh) Up'); %fire up the titlefig1Title = get(fig1Axes,'Title'); % handle of title, need it for later b/c rotation moves title locationset(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 positionset(fig1Title,'Position',defaultTitlePosition); % Shift the position upwarddefaultTitlePosition_Mag = norm(defaultTitlePosition); %get mag of the default title position for rotation calcsfig1Axes_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) = []; %deleteaxOverlay = axes('Parent', fig1); %create independent axes for the two plots (TEC and AMPERE)linkaxes([fig1Axes,axOverlay]); %link emhOverlay = 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 setaxOverlay.YTick = []; %hide the 2nd axes setpbaspect(axOverlay,[1 1 1])xlim(axOverlay,[-plotScaleFactor, plotScaleFactor]); %force axis to be this
ylim(axOverlay,[-plotScaleFactor, plotScaleFactor]); %force axis to be thisset(axOverlay, 'CameraViewAngleMode', 'manual');hold on;disp('3 No 2nd Geoshow Run - 2nd plot reported position:');get(axOverlay,'Position')%ROTATEangle = 35*pi/180; %degset(fig1Axes,'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angleset(axOverlay, 'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an anglerotatedTitlePosition = [defaultTitlePosition_Mag*cos(angle) , defaultTitlePosition_Mag*sin(angle) , 0]; %calc new top once the plot has been rotatedset(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 whitefig1Axes = axes('Parent', fig1); %gets a reference to the axes for laterset(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 offframem ongridm onmlabel onplabel on;setm(gca,'MLabelParallel',0,'FFaceColor', [.5 .7 .9]); %FFaceColor sets ocean colorhMap = 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 plottitle('4 No Geoshow, But with Resize - But Plot Can''t Line (heh) Up'); %fire up the titlefig1Title = get(fig1Axes,'Title'); % handle of title, need it for later b/c rotation moves title locationset(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 positionset(fig1Title,'Position',defaultTitlePosition); % Shift the position upwarddefaultTitlePosition_Mag = norm(defaultTitlePosition); %get mag of the default title position for rotation calcsfig1Axes_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 coordscoastLines_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 GEOSHOWcoastLines_lat_Circ(k) = []; %deletecoastLines_long_Circ(k) = []; %deleteaxOverlay = axes('Parent', fig1); %create independent axes for the two plots (TEC and AMPERE)linkaxes([fig1Axes,axOverlay]); %link emhOverlay = plot(axOverlay,coastLines_long_Circ,coastLines_lat_Circ,'Color','k'); %add continental outlines in black axOverlay.Visible = 'off'; %hide the 2nd axes setaxOverlay.XTick = []; %hide the 2nd axes setaxOverlay.YTick = []; %hide the 2nd axes setpbaspect(axOverlay,[1 1 1])xlim(axOverlay,[-plotScaleFactor, plotScaleFactor]); %force axis to be thisylim(axOverlay,[-plotScaleFactor, plotScaleFactor]); %force axis to be thisset(axOverlay, 'CameraViewAngleMode', 'manual');hold on;disp('4 No 2nd Geoshow Run - 2nd plot reported position:');get(axOverlay,'Position')%ROTATEangle = 35*pi/180; %degset(fig1Axes,'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an angleset(axOverlay, 'CameraUpVector', [cos(angle), sin(angle), 0]); %rotate an anglerotatedTitlePosition = [defaultTitlePosition_Mag*cos(angle) , defaultTitlePosition_Mag*sin(angle) , 0]; %calc new top once the plot has been rotatedset(fig1Title,'Position',rotatedTitlePosition); %Apply the new top position so title stays where it should
Best Answer