| Contents | Index |
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
.
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.
Calls:
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)
Parameters:
|
f1, f2: |
the outlining function(s) of the hatch: objects of type plot::Function2d. |
|
c: |
the outlining curve of the hatch: a parametrized curve of type plot::Curve2d. |
|
base: |
the base line of the hatch: a numerical real value or an arithmetical expression of the animation parameter a. |
|
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. |
See Also:
plot, plot::copy, plot::Curve2d, plot::Function2d, plot::Sweep
Details:
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
. 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
. See example 4.
The attributes FillColor and FillPattern can be used to change the color and pattern of the hatched area. See example 5.
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.
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 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
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
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))


Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |