Offset, Scaled

? Offset

Offset[{dx, dy}, position] gives the position of a graphical object obtained by starting at the specified position and then moving by absolute offset {dx, dy}.

In the next cell pnt1 is a red point at {1,0.025}.  The graphic made also shows pnt2, a blue point 20 printer points to the right and 10 printer points above {1,0.025}.  Notice distances in printer points aren't related to the scale on the axes.

RowBox[{RowBox[{RowBox[{pnt1, =, RowBox[{Graphics, [, RowBox[{{, RowBox[{RowBox[{PointSize, [, ...  5}, ,, RowBox[{{, RowBox[{RowBox[{-, 0.1}], ,, 0.1}], }}]}], }}]}], ,, Axes->True}], ]}], ;}]

The remaining examples used Offset and Scaled.

? Scaled

Scaled[{x, y, ... }] gives the position of a graphical object in terms of coordinates scaled t ... by starting at ordinary coordinates {x0, y0, ... }, then moving by a scaled offset {dx, dy, ... }.

In the next cell pnt1 is a red point positioned such that the distance from the left edge of the graphic is 10% of the graphic width, and and the distance from the bottom of the graphic is 5% of the graphic height. Also shown is pnt2, a blue point 20 printer points to the right and 10 printer points above pnt1.

RowBox[{RowBox[{pnt1, =, RowBox[{Graphics, [, RowBox[{{, RowBox[{RowBox[{PointSize, [, 0.03, ] ...  5}, ,, RowBox[{{, RowBox[{RowBox[{-, 0.1}], ,, 0.1}], }}]}], }}]}], ,, Axes->True}], ]}], ;}]

In the next cell pnt1 is a red point at {1,0.025}.  Also shown is pnt2, a blue point at the position FormBox[RowBox[{Scaled, [, RowBox[{RowBox[{{, RowBox[{0.1, ,, 0.05}], }}], ,, RowBox[{{, RowBox[{1, ,, 0.025}], }}]}], ]}], TraditionalForm] which is to the right of pnt1 by 10% of the graphic width, and above pnt1 by 5% of the graphic height.  In addition pnt3 is shown which is a green point 10 printer points to the right of pnt2, and 20 printer points higher than pnt2.

RowBox[{RowBox[{pnt1, =, RowBox[{Graphics, [, RowBox[{{, RowBox[{RowBox[{PointSize, [, 0.03, ] ...  5}, ,, RowBox[{{, RowBox[{RowBox[{-, 0.1}], ,, 0.1}], }}]}], }}]}], ,, Axes->True}], ]}], ;}]

A practical use of Offset is given in the next cell where it's used to specify the position of some text.

RowBox[{RowBox[{RowBox[{plt, =, RowBox[{Plot, [, RowBox[{BesselJ[2, x], ,, {x, 0, 8}, ,, Displ ... , ]}], , }}], ]}]}], ;}] Show[{plt, pnt, txt}, DisplayFunction$DisplayFunction] ;


Created by Mathematica  (May 16, 2004)

Back to Ted’s Tricks index page