plot::Hatch

Hatched area

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

plot::Hatch(f1, f2, <x1 .. x2>, <a = amin .. amax>, options)
plot::Hatch(f1, <base>, <x1 .. x2>, <a = amin .. amax>, options)
plot::Hatch(c, <a = amin .. amax>, options)

Description

plot::Hatch(f) hatches the area between the function f and the x-axis.

plot::Hatch(f, base) hatches the area between the function f and the horizontal line y = base.

plot::Hatch(f, g) hatches the area between the two functions f and g.

plot::Hatch(c) hatches the area enclosed by the curve c.

plot::Hatch(f, base) is the hatched area between a function f of type plot::Function2d and a line parallel to the x-axis with y = base. If base is omitted, the area between the function and the x-axis will be hatched (the baseline is assumed to be the x-axis). See Example 1.

plot::Hatch( f1, f2) is the hatched area between two functions f1 and f2. See Example 2.

plot::Hatch(c) is the hatched area enclosed by a plot::Curve2d. A curve is closed automatically by connecting the starting point and the end point. See Example 3.

The hatch may be restricted to the left and to the right by a range x_..x_. See Example 4.

The attributes FillColor and FillPattern can be used to change the color and pattern of the hatched area. See Example 5.

    Note:   A plot::Hatch is only the hatched area without outlining functions or curves! To see the border lines, you need to plot them separately as demonstrated in the examples.

Attributes

AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
AntiAliasedantialiased lines and points?TRUE
Baselineconstant second function delimiting hatch 
Colorthe main colorRGB::Red
FillColorcolor of areas and surfacesRGB::Red
FillPatterntype of area fillingDiagonalLines
Framesthe number of frames in an animation50
Function1first function/curve delimiting hatch 
Function2second function delimiting hatch 
Legendmakes a legend entry 
LegendTextshort explanatory text for legend 
LegendEntryadd this object to the legend?FALSE
Namethe name of a plot object (for browser and legend) 
ParameterEndend value of the animation parameter 
ParameterNamename of the animation parameter 
ParameterBegininitial value of the animation parameter 
ParameterRangerange of the animation parameter 
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title 
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles 
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component 
TitlePositionYposition of object titles, y component 
VisiblevisibilityTRUE
VisibleAfterobject visible after this time value 
VisibleBeforeobject visible until this time value 
VisibleFromToobject visible during this time range 
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE
XMaxfinal value of parameter "x"infinity
XMininitial value of parameter "x"-infinity
XRangerange of parameter "x"-infinity .. infinity

Examples

Example 1

If given a single plot::Function2d object, plot::Hatch hatches the area between the curve and the x-axis:

f := plot::Function2d(sin(x), x = -PI..PI):
plot(plot::Hatch(f), f)

Note that plot::Hatch requires an object of type plot::Function2d, not just a function expression:

plot::Hatch(sin(x))
Error: No 'plot::Function2d' or 'plot::Curve2d' is given. [plot::Hatch::new]

plot::Hatch can be asked to hatch the area between a function graph and some constant value (i.e., some line parallel to the x-axis):

plot(plot::Hatch(f, 1), f)

For functions with poles, keeping VerticalAsymptotesVisible set to TRUE is highly recommended:

f := plot::Function2d(1/(x - 1)):
h := plot::Hatch(f):
plot(f, h)

delete f, h:

Example 2

By passing two functions to plot::Hatch, we ask for a hatch of the area between the two:

f := plot::Function2d(sin(x), x = -4 .. 4,  Color = RGB::Blue):
g := plot::Function2d(cos(2*x), x = -4 .. 4, Color=RGB::Black):
h := plot::Hatch(f, g):
plot(f, g, h)

delete f, g, h:

Example 3

plot::Hatch can also hatch the inner part of a plot::Curve2d object:

circle := plot::Curve2d([sin(t), cos(t)], t=0..2*PI):
plot(circle, plot::Hatch(circle))

If the curve is not closed, plot::Hatch regards the first and last point to be connected:

circle::UMax := 3*PI/2:
plot(circle, plot::Hatch(circle))

delete circle:

Example 4

By default, plot::Hatch extends as far to the left and right as possible without leaving the common definition area of all given functions:

f := plot::Function2d(sin(x), x = 0 .. 5):
g := plot::Function2d(-cos(x), x = -1 .. 4):
h := plot::Hatch(f, g):
plot(f, g, h)

You can restrict this range by giving an explicit range of x values:

h := plot::Hatch(f, g, 1 .. 3):
plot(f, g, h)

However, it is not possible to extend the range beyond the common definition range of both functions:

h := plot::Hatch(f, g, -1 .. 3):
plot(f, g, h)

The restriction of the x range also works for hatching curve objects:

c := plot::Curve2d([sin(5*x), cos(7*x)], x = 0 .. 2*PI):
h := plot::Hatch(c, 0 .. 1):
plot(c, h)

Note that plot::Hatch reacts to the smoothness of the curve. This is one of the reasons why you have to provide a objects instead of expressions for the functions or curves:

c::AdaptiveMesh := 2:
plot(c, h)

delete f, g, h, c:

Example 5

One of the most useful attributes of plot::Hatch is FillPattern, which can take one of the values DiagonalLines (the default), FDiagonalLines, HorizontalLines, VerticalLines, CrossedLines, XCrossedLines, or Solid:

f := plot::Function2d(sin(x)):
h := plot::Hatch(f, FillPattern = VerticalLines):
plot(f, h)

Another attribute that will often be useful is FillColor, to change the color of the hatch. We set the value right in our existing hatch object:

h::FillPattern := CrossedLines:
h::FillColor := RGB::Blue:
plot(f, h)

delete f, h:

Example 6

The function(s) or curve, the baseline, and the restriction of the x range can be animated:

f := plot::Function2d(sin(x + a), x = -PI..PI, a = 0..2*PI):
g := plot::Function2d(cos(x - a), x = -PI..PI, a = 0..4*PI):
plot(f, g, plot::Hatch(f, g, x0 .. x0+1, x0 = -PI..3))

f := plot::Function2d(sin(a*x), x=-PI..PI, a=0.2..3):
plot(f, plot::Hatch(f))

delete f, g:

Example 7

A "hatch" may also be a solid area fill:

plot(plot::Hatch(
  plot::Curve2d([abs(r)*sin(r), abs(r)*cos(r)], r = -PI..PI),
  FillPattern = Solid, FillColor = RGB::Red, Axes = None))

Parameters

f1, f2

The outlining function(s) of the hatch: objects of type plot::Function2d.

f1, f2 are equivalent to the attributes Function1, Function2.

c

The outlining curve of the hatch: a parametrized curve of type plot::Curve2d.

c is equivalent to the attribute Function1.

base

The base line of the hatch: a numerical real value or an arithmetical expression of the animation parameter a.

base is equivalent to the attribute Baseline.

x1 .. x2

A range on the x-axis limiting the hatch to the left and the right hand side:numerical real values or arithmetical expressions of the animation paramater a.

x1 .. x2 is equivalent to the attributes XMin, XMax, XRange.

a

Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.

See Also

MuPAD Functions

MuPAD Graphical Primitives

Was this topic helpful?