GridVisible, SubgridVisible, XGridVisible, XSubgridVisible, YGridVisible, YSubgridVisible, ZGridVisible, ZSubgridVisible

Display a coordinate grid?

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Value Summary

GridVisibleLibrary wrapper for “{XGridVisible, YGridVisible}” (2D), “{XGridVisible, YGridVisible, ZGridVisible}” (3D)See below
SubgridVisibleLibrary wrapper for “{XSubgridVisible, YSubgridVisible}” (2D), “{XSubgridVisible, YSubgridVisible, ZSubgridVisible}” (3D)See below
XGridVisible, XSubgridVisible, YGridVisible, YSubgridVisible, ZGridVisible, ZSubgridVisibleInheritedFALSE, or TRUE

Graphics Primitives

ObjectsDefault Values
plot::CoordinateSystem2d

GridVisible, SubgridVisible, XGridVisible, XSubgridVisible, YGridVisible, YSubgridVisible: FALSE

plot::CoordinateSystem3d

GridVisible, SubgridVisible, XGridVisible, XSubgridVisible, YGridVisible, YSubgridVisible, ZGridVisible, ZSubgridVisible: FALSE

Description

With GridVisible = TRUE versus GridVisible = FALSE, a coordinate grid extending the “major” axes tick marks is “switched on” or “off”.

With SubgridVisible, additional grid lines extending the “minor” axes tick marks are switched on or off.

With XGridVisible, XSubgridVisible etc., the coordinate lines can be switched on or off separately for each single coordinate direction.

The regular equidistant tick marks along the coordinate axes consist of “minor” tick marks without labels (cf. TicksBetween) between “major” tick marks bearing labels (cf. TicksNumber, TicksAnchor, TicksDistance).

Extending the major tick marks, one obtains a grid of coordinate lines. Likewise, extending the minor tick marks yields a refined subgrid of coordinate lines.

With GridVisible = TRUE, the coordinate grid extending the major tick marks is displayed. With SubgridVisible = TRUE, the refined subgrid is displayed.

With XGridVisible = TRUE, XSubgridVisible = TRUE, only the coordinate lines passing through the ticks along the x-axis are displayed. Likewise, YGridVisible, YSubgridVisible, ZGridVisible, ZSubgridVisible allow to display the coordinate lines passing through the ticks along the y and z-axis, respectively.

The coordinate grid is controlled by the ticks marks displayed along the coordinate axes.

Use TicksNumber to control the number of automatically generated major tick marks. Alternatively, use TicksAnchor, TicksDistance to specify the major tick marks explicitly.

Use TicksBetween to control the number of minor tick marks.

Non-regular tick marks added via TicksAt do not generate additional grid lines.

Examples

Example 1

We plot the graph of the sine function without grid lines:

plot(plot::Function2d(sin(x), x = 0..2*PI),
     XTicksNumber = Normal, YTicksNumber = High)

The grid lines are “switched on”:

plot(plot::Function2d(sin(x), x = 0..2*PI),
     XTicksNumber = Normal, YTicksNumber = High,
     GridVisible = TRUE):

The subgrid lines are switched on as well:

plot(plot::Function2d(sin(x), x = 0..2*PI),
     XTicksNumber = Normal, YTicksNumber = High,
     GridVisible = TRUE, SubgridVisible = TRUE):

We refine the subgrid in the x-direction via XTicksBetween:

plot(plot::Function2d(sin(x), x = 0..2*PI),
     XTicksNumber = Normal, XTicksBetween = 4,
     YTicksNumber = High,
     GridVisible = TRUE, SubgridVisible = TRUE):

Example 2

We consider the probabiliy of at least k successes when performing 10 independent experiments each with a 50% chance of success. Consider for this the cumulative density of the binomial distribution given by stats::binomialCDF. Quantiles are visualized by introducing horizontal grid lines:

f := stats::binomialCDF(10, 0.5):
plot(plot::Bars2d([f(k) $ k = 0..10]),
     XTicksDistance = 1, XTicksBetween = 0,
     XAxisVisible,
     YTicksDistance = 0.1, YTicksBetween = 4,
     YGridVisible, YSubgridVisible)

delete f:

Example 3

Consider a curve in 3D with two of its projections to the coordinate planes. We render the coordinate grid visible:

c1 := plot::Curve3d([t, cos(t)/t, sin(t)], t = 1..10,
                    LineColor = RGB::Red):
c2 := plot::Curve3d([1, cos(t)/t, sin(t)], t = 1..10,
                    LineColor = RGB::ForestGreen):
c3 := plot::Curve3d([t, cos(t)/t, -1], t = 1..10,
                    LineColor = RGB::Blue):
plot(c1,c2, c3, TicksBetween = 4, GridVisible = TRUE, 
     SubgridVisible = TRUE)

delete c1, c2, c3:

Example 4

Because of the rather large number of grid lines in the following plot, we use extra fine lines to render the subgrid:

plot(plot::Function3d(cos(x*PI)*cos(y*PI), x = 0 .. 2,
                      y = 0 .. 2),
     TicksNumber = Low, TicksBetween = 9,
     GridVisible = TRUE, SubgridVisible = TRUE,
     GridLineWidth = 0.5*unit::mm,
     SubgridLineWidth = 0.1*unit::mm)