Main Content

axesscale

Resize axes for equivalent scale

Description

axesscale resizes all axes in the current figure to have the same scale as the current axes (gca). In this context, scale means the relationship between axes x- and y-coordinates and figure and paper coordinates. When axesscale is used, a unit of length in x and y is printed and displayed at the same size in all the affected axes. The XLimMode and YLimMode of the axes are set to 'manual' to prevent autoscaling from changing the scale.

axesscale(hbase) uses the axes hbase as the reference axes, and rescales the other axes in the current figure.

example

axesscale(hbase,hother) uses the axes hbase as the base axes, and rescales only the axes in hother.

Examples

collapse all

Display the conterminous United States, Alaska, and Hawaii in separate axes in the same figure, with a common scale.

Read state names and coordinates. Extract Alaska and Hawaii.

states = readgeotable("usastatehi.shp");
alaska = states(states.Name == "Alaska",:);
hawaii = states(states.Name == "Hawaii",:);

Create a figure for the conterminous states.

f = figure;
hconus = usamap("conus");
geoshow(states,"FaceColor",[0.5 1 0.5]);
load conus gtlakelat gtlakelon
geoshow(gtlakelat,gtlakelon,...
    "DisplayType","polygon","FaceColor","cyan")
framem off
gridm off
mlabel off
plabel off

Figure contains an axes object. The hidden axes object contains 50 objects of type patch.

Display Alaska and Hawaii on different axes. For now, the axes overlap.

halaska = axes("Parent",f);
usamap("alaska")
geoshow(alaska,"FaceColor",[0.5 1 0.5]);
framem off
gridm off
mlabel off
plabel off

hhawaii = axes("Parent",f);
usamap("hawaii") 
geoshow(hawaii,"FaceColor",[0.5 1 0.5]);
framem off
gridm off
mlabel off
plabel off

Figure contains 3 axes objects. Hidden axes object 1 contains 50 objects of type patch. Hidden axes object 2 contains an object of type patch. Hidden axes object 3 contains an object of type patch.

Arrange the axes so they do not overlap. However, this changes the scale of the axes.

set(hconus, "Position",[0.1   0.35 0.85 0.6])
set(halaska,"Position",[0.02  0.08 0.2  0.2])
set(hhawaii,"Position",[0.5   0.1  0.2  0.2])

Figure contains 3 axes objects. Hidden axes object 1 contains 50 objects of type patch. Hidden axes object 2 contains an object of type patch. Hidden axes object 3 contains an object of type patch.

Resize the Alaska and Hawaii axes based on the size of the conterminous United States.

axesscale(hconus)

Figure contains 3 axes objects. Hidden axes object 1 contains 50 objects of type patch. Hidden axes object 2 contains an object of type patch. Hidden axes object 3 contains an object of type patch.

Limitations

The equivalence of scales holds only as long as no commands are issued that can change the scale of one of the axes. For example, changing the units of the ellipsoid or the scale factor in one of the axes would change the scale.

Tips

To ensure the same map scale between axes, use the same ellipsoid and scale factors.

Version History

Introduced before R2006a

See Also