# Scaling, YXRatio, ZXRatio

Scaling ratios

## Value Summary

 `Scaling` Inherited `Automatic`, `Constrained`, or `Unconstrained` `YXRatio`, `ZXRatio` Inherited Positive real numberReal number

## Graphics Primitives

ObjectsDefault Values
`plot::CoordinateSystem2d`, `plot::CoordinateSystem3d`

`Scaling`: `Unconstrained`

`plot::Scene3d`

`YXRatio`: `1`

`ZXRatio`: `2/3`

## Description

With `Scaling = Constrained`, the graphics output is scaled like the model coordinates, i.e., circle appear as circles, spheres as spheres.

With `Scaling = Unconstrained`, the graphics output is scaled independently in each coordinate direction such that the graphics fits optimally into the viewing area. Circles may appear as ellipses, spheres as ellipsoids.

For `Scaling = Unconstrained`, the scaling ratios of the different coordinate directions in a 3D plot can be set via the attributes `YXRatio` and `ZXRatio`.

If the graphics consists of geometrical objects such as circles, pie charts, spheres etc., the setting `Scaling = Constrained` is appropriate. This prevents circles from being deformed to ellipses in the graphical output.

For the visualization of non-geometrical data (usually, in function plots etc.), a scaling constrained to model coordinates is usually not appropriate. Think of the graph of y = ex for , where the y values extend over the range , which is roughly . With `Scaling = Constrained`, the graphical output would consist of a narrow vertical strip with the side ratio ```y : x = 22025 : 10```. Here, `Scaling = Unconstrained` is appropriate.

The default value is `Scaling = Unconstrained`. However, many "geometrical" objects in the MuPAD® `plot` library override this default setting via the "hint mechanism" (see section Primitives Requesting Special Scene Attributes: "Hints" in this document). Whenever such an object is plotted in a scene, the whole scene uses `Scaling = Constrained`. A complete list of these "geometrical objects" such as circles, spheres, cones etc. is given further up on this help page.

With `Scaling = Automatic`, the graphics uses ```Scaling = Constrained``` for plots in which the coordinate ranges to be displayed have a ratio close to `1 : 1` in 2D or `1 : 1 : 1` in 3D. Otherwise, ```Scaling = Unconstrained``` is used.

The attributes `YXRatio = r1` and ```ZXRatio = r2``` only have an effect in 3D with ```Scaling = Unconstrained```. The graphical scene is scaled to a box with side ratios ```z : y : x = r2: r1: 1```. On the screen, the bounding box of the scene looks like a box with these side ratios.

## Examples

### Example 1

We plot a scene containing a function graph and some circles highlighting the extrema. Because the circle sends the "hint"`Scaling` = `Constrained`, this scaling is used for the whole scene. Consequently, the circles appear as circles:

```plot(plot::Function2d(sin(x), x = 0 .. 2*PI), plot::Circle2d(0.2, [PI/2, 1], Color = RGB::Black), plot::Circle2d(0.2, [3*PI/2, -1], Color = RGB::Black), BorderWidth = 1.0*unit::mm, Header = "Scaling = Constrained")```

With `Scaling = UnConstrained`, we get a better fit of the plot in the canvas. However, the circles are deformed to ellipses:

```plot(plot::Function2d(sin(x), x = 0 .. 2*PI), plot::Circle2d(0.2, [PI/2, 1], Color = RGB::Black), plot::Circle2d(0.2, [3*PI/2, -1], Color = RGB::Black), Scaling = Unconstrained, BorderWidth = 1.0*unit::mm, Header = "Scaling = Unconstrained")```

### Example 2

A sphere of type `plot::Sphere` sends the "hint" `Scaling` = `Constrained`. With this scaling, `YXRatio`, `ZXRatio` have no effect:

```s := plot::Sphere(1, [0, 0, 0]): plot(s, BorderWidth = 0.5*unit::mm, Header = "Scaling = Constrained", YXRatio = 3, ZXRatio = 10)```

We use `Scaling = Unconstrained`. With the default values `YXRatio = 1`, ```ZXRatio = 2/3```, the objects in a 3D scene are displayed like a box with side ratios `X : Y : Z = 3 : 3 : 2`:

```plot(s, BorderWidth = 0.5*unit::mm, Scaling = Unconstrained, Header = "X:Y:Z = 3:3:2")```

We request different scaling ratios:

```plot(s, BorderWidth = 0.5*unit::mm, Header = "X:Y:Z = 5:5:1", Scaling = Unconstrained, YXRatio = 1, ZXRatio = 1/5, BorderWidth = 0.5*unit::mm)```

```plot(s, BorderWidth = 0.5*unit::mm, Header = "X:Y:Z = 7:3:1", Scaling = Unconstrained, YXRatio = 3/7, ZXRatio = 1/7, BorderWidth = 0.5*unit::mm)```

`delete s:`