1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Kỹ thuật lập trình >

3 Options for Axes, Frames, and Primitives

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (18.67 MB, 1,135 trang )


Chapter 7 • Graphics Options



191



7.2.3 Margins and Background

PlotRegion Specifies margins around the plot inside the selection rectangle; examples of values:

Automatic (means {{0, 1}, {0, 1}}), {{xmin, xmax}, {ymin, ymax}}

(ImageMargins Specifies margins (in printer’s points) outside the selection rectangle; examples of

values: 0, Automatic, 15, {{left, right}, {bottom, top}})

Background Color of the background; examples of values: None, LightGray



Each plot has a display area that can be seen by clicking the plot: A rectangle around the plot appears.

The curve normally fills this area, but with PlotRegion we can define other ways for the curve to be

placed in the display area. The plot region is given in scaled coordinates ranging from 0 to 1 in each

direction. The default setting Automatic is the same as {{0, 1}, {0, 1}}, which is the whole display

area. By specifying other values (values less than 0 and greater than 1 are allowed), we can adjust the

margins around the curve in the display area. For example, plots with gray or colored backgrounds

often look better with a somewhat reduced plot region (i.e., with larger margins). The second plot

shown here has a wider margin around the plot than the first plot. In the third plot, the margin is

outside the selection rectangle.

GraphicsRow@

8Plot@Sin@xD, 8x, 0, 2 p<, Background Ø LightGray, PlotRegion Ø AutomaticD,

Plot@Sin@xD, 8x, 0, 2 p<, Background Ø LightGray,

PlotRegion Ø 880.1, 0.9<, 80.1, 0.9<
Background Ø LightGray, ImageMargins Ø 10D<, ImageSize Ø 420D

1.0



1.0

1.0

0.5



0.5



-0.5



1



2



3



4



5



6



0.5

1 2 3 4 5 6



-0.5

-1.0



-1.0



-0.5



1



2



3



4



5



6



-1.0



(ImagePadding (Ÿ6) Extra space (in printer’s points) for objects such as thick lines and tick and axes

labels; examples of values: All, None, 15, {{left, right}, {bottom, top}})

(PlotRangePadding (Ÿ6) How much further axes etc. should extend beyond the range of coordinates specified by PlotRange; examples of values: Automatic, None, {0.2, 0.5})

The first plot below shows that usually the axes are a little extended (2% in each direction) from the

given x range and the range of y values. In the second plot, we use no padding, and in the third plot we

use unusually wide padding. No padding is used if an explicit plot range is used.



Plot@Sin@xD, 8x, 0, 2 p<, PlotRangePadding Ø ÒD & êü 8Automatic, None, 80.5, 0.2<<



:



1.0



1.0



0.5



0.5

1



2



3



4



5



6



,



0.0



1.0

0.5



,

1



2



3



4



5



6



1



-0.5



-0.5



-0.5



-1.0



-1.0



-1.0



2



3



4



5



6



>



192



Mathematica Navigator



7.2.4 Fonts

All text in a plot is, by default, written with the Times font of size 10. We can change the font properties

at various levels: for all plots during a session, for all texts in a single plot, for all labels in a single plot,

and for a text item inside a plot. Here is a summary:

Setting font properties at various levels:

SetOptions[Plot, BaseStyle Ø {font directives and options}]



For all plots in a session:

For all texts in a plot:

For all labels in a plot:

For a text item:

Note



that



the



BaseStyle Ø {font directives and options}

LabelStyle Ø {font directives and options}

Style[expr, {font directives and options}]



more



specific



style



options



AxesStyle,



TicksStyle,



FrameStyle,



and



FrameTicksStyle can be used to adjust fonts in axes labels, tick labels, frame labels, and frame tick



labels. See Section 7.3.5, p. 200, for a discussion of the hierarchy of styles on plots. Next, we consider

BaseStyle, LabelStyle, SetOptions, and Style in detail.

‡ Setting Font Properties for All Texts or Labels in a Plot

* BaseStyle Ø {font directives and options} (Ÿ6)



The font styles given in BaseStyle apply for all texts in a plot: for plot label, axes labels, tick labels,

frame labels, frame tick labels, and Text primitives. In defining the style of font, we can use font

directives such as 7 (font size), Bold, and Italic and font options such as FontFamily and FontColor.

Examples:

BaseStyle Ø 7

BaseStyle Ø 87, Bold, Italic<

BaseStyle Ø 87, Bold, FontFamily Ø "Helvetica"<



In the next example, we use bold Helvetica in size 7:



Plot@Sin@xD, 8x, 0, 2 p<, AxesLabel Ø 8x, Sin@xD<,

BaseStyle Ø 87, Bold, FontFamily Ø "Helvetica"
sinHx L

1.0

0.5

1



2



3



4



5



6



x



-0.5

-1.0



The next boxes give font directives and font options.

Font directives:

n, Tiny, Small, Medium, Large, Smaller, Larger

Bold, Italic, Underlined, Plain

Red, LightBlue, GrayLevel[0.3], etc.



Chapter 7 • Graphics Options



193



Font options:

FontFamily; examples of values: "Times", "Helvetica", "Courier"

FontColor; examples of values: Red, Gray

FontTracking; examples of values: "Narrow", "Condensed", "SemiCondensed", "Extended", "Wide"

Background; examples of values: LightGray, LightBlue



Instead of the directives, we can use the options FontSize, FontWeight, FontSlant, and FontColor.

If we want to define a color for all text with BaseStyle, a definition such as BaseStyle Ø Red causes the

axes and labels to also be colored. Thus, font color should be defined by using FontColor, as in

BaseStyle Ø {FontColor Ø Red}.

If you export Mathematica figures in, for example, EPS form into another application such as TEX and

encounter problems with special characters appearing in the plots, one solution may be to render the

document in the front end (and not in the printer). To do this, choose Format @ Option Inspector…, set

Show option values for to be notebook, then go to Notebook Options @ Printing Options @ PrintingOptions and change the value of GraphicsPrintingFormat from Automatic to RenderInFrontEnd. Now

when you print a document, it is rendered in the front end.

LabelStyle Ø {font directives and options} (Ÿ6)

LabelStyle applies for all labels in a plot (i.e., for plot labels, axes labels, tick labels, frame labels,

and frame tick labels) but not for Text primitives.

‡ Setting Font Properties for a Session



Usually, the same style of text is used for all plots in a document or in a session. The style definitions

need not be done for each plot separately because we can set, with SetOptions, the value of BaseStyle

so that the given value is used during the rest of the current session.

SetOptions[Plot, BaseStyle Ø {font directives and options}]



For example, to use the Helvetica font of size 8 during a session, simply execute, at the beginning of

the session, the following command:

SetOptions@Plot, BaseStyle Ø 88, FontFamily Ø "Helvetica"


If you want to use the same text style for several plotting commands, write, for example,

SetOptions@8Plot, ListPlot, ListLinePlot<,

BaseStyle Ø 88, FontFamily Ø "Helvetica"


The font properties can also be defined in the init.m file; the definitions then hold automatically for all

sessions, unless you change the definitions (see Section 4.1.1, p. 96).

‡ Setting Font Properties for a Text Item



Sometimes we want to use varying font properties for several text items in a plot. We can then define

the font used most often with the BaseStyle and use Style in places where we want to use special font

properties.

Style[expr, {font directives and options}] (Ÿ6)



194



Mathematica Navigator



The font directives and options need not even be given as a list; they can simply be written separated

by commas. For colors, we need not use the FontColor option; just write the color specification. Here

are some examples:

f = Exp@xD ArcTan@xD ê Sqrt@xD;



8Plot@f, 8x, 0, 5<, PlotLabel Ø Framed@Style@f, 8, BlueDD, ImageSize Ø 110D,

Plot@f, 8x, 0, 5<, AxesLabel Ø HStyle@Ò, 8, RedD & êü 8x, f
Plot@f, 8x, 0, 5<, Epilog Ø Text@Style@f, 8, Background Ø LightGrayD, 82.7, 73
‰x tan-1 Hx L



‰x tan-1 Hx L



x



x



: 80



,



80



,



60



60



‰x tan-1 Hx L



60



x



>



40

20



40



40



80



20



20

0



1



2



3



4



0



5



1



2



3



4



5



x



1



2



3



4



5



‡ Setting Font Properties in a Style Sheet



The font style in graphics can also be defined in a style sheet. In Section 3.2.2, p. 63, we showed how to

change styles. Using this technique, we can change the style of Graphics cells.

• Choose Edit Stylesheet… from the Format menu. A notebook appears with the title Private Style

Definitions for ….

• In the Enter a style name input field, write Graphics; the corresponding style definition cell appears

in the document. Edit this cell with the Format menu by defining, for example, a font.

• Thus far, the new Graphics style holds for the current notebook. You can also save the style sheet so

that you can use it for any notebook (see Section 3.2.2).

‡ Formatting



(FormatType Format type of text used in a plot; examples of values: TraditionalForm,

StandardForm, InputForm, OutputForm)

These types of formatting are considered in Section 3.3.1, p. 70. The default is to use traditional

formatting~that is, the type of formatting used in traditional mathematical typesetting: The font is

Times, all variables are in italic, and all formulas are typeset according to traditional mathematical

notation. These properties can be seen in the first plot:

Plot@f, 8x, 0, 5<, AxesLabel Ø 8x, y<, PlotLabel Ø f,

FormatType Ø Ò, ImageSize Ø 110D & êü 8TraditionalForm, StandardForm<



‰x tan-1 HxL



‰x ArcTan@xD



x

:80

60

40

20



x



y



>



y



1



2



3



4



5



, 80

60

40

20

x



x

1



2



3



4



5



Chapter 7 • Graphics Options



195



7.2.5 Miscellaneous Options

(BaselinePosition (Ÿ6) Where the baseline of a plot should be if the plot is combined with other

plots or text; examples of values: Automatic, Axis, Bottom, Top, Center, Baseline)

(AlignmentPoint (Ÿ6) How objects should by default be aligned when they appear in Inset;

default value: Center)

(ContentSelectable (Ÿ6) Whether and how content of a plot should be selectable; possible values:

Automatic (double-click allows content selection), True (single clicks immediately select content

objects), False (content objects cannot be selected))

(PreserveImageOptions (Ÿ6) Whether the size and margins of a plot should remain the same if the

plotting command is executed anew; examples of values: Automatic (the properties should remain

the same if not explicitly otherwise stated), True (the properties should remain the same), False

(the previous properties are ignored))

(DisplayFunction Function to apply to a graphic; default value: $DisplayFunction

With BaselinePosition we can ask to align several plots according to the x axis:



Row@8Plot@Sin@xD, 8x, 0, 2 p<, BaselinePosition Ø Axis, ImageSize Ø 120D,

Plot@Exp@xD, 8x, 0, 3<, BaselinePosition Ø Axis, ImageSize Ø 120D,

Plot@Log@xD, 8x, 0, 3<, BaselinePosition Ø Axis, ImageSize Ø 120D<, "

"D

20

15

1.0



10



0.5



5

1



2



3



4



5



1

0.5



6



1.0



1.5



2.0



2.5



3.0



0.5



-0.5



-1



-1.0



-2



1.0



1.5



2.0



2.5



3.0



7.3 Options for Axes, Frames, and Primitives

7.3.1 Plot Label

PlotLabel Label of the plot; examples of values: None, Sin[x/2], "Function g(x)"



With Style we can modify the style of the plot label:



8Plot@Sin@x ê 2D, 8x, 0, 4 p<, PlotLabel Ø Sin@x ê 2DD, Plot@Sin@x ê 2D,

8x, 0, 4 p<, PlotLabel Ø Style@Sin@x ê 2D, 9, Red, FontFamily Ø "Helvetica"DD<

x



x



sin



sin



2



:



2



1.0



1.0



0.5



,

2



4



6



8



10



>



0.5



12



2



-0.5



-0.5



-1.0



-1.0



4



6



8



10



12



196



Mathematica Navigator



Sometimes we want to vary a parameter in the label:



Table@Plot@Sin@n xD, 8x, 0, 2 p<,

PlotLabel Ø Row@8"The graph of ", Sin@n xD
The graph of sinHx L



The graph of sinH2 x L



1.0



:



1.0



0.5



0.5

2



3



4



5



>



0.5



,

1



The graph of sinH3 x L

1.0



,



6



1



2



3



4



5



6



1



-0.5



-0.5



-0.5



-1.0



-1.0



-1.0



2



3



4



5



6



Next, we give a plot a more complete caption:



8Plot@Sin@x ê 2D, 8x, 0, 4 p<, ImageSize Ø 160, PlotLabel Ø

Style@Row@8Style@"Figure 1.1 ", BoldD, "The graph of ", Sin@x ê 2D
Labeled@Plot@Sin@x ê 2D, 8x, 0, 4 p<, ImageSize Ø 160D,

Style@Row@8Style@"Figure 1.1 ", BoldD, "The graph of ",

Sin@x ê 2D êê TraditionalForm


x

Figure 1.1 The graph of sin



1.0



2

1.0



:



0.5

0.5



,

2

2



4



6



-0.5

-1.0



8



10



12



4



6



8



10



12



>



-0.5

-1.0



Figure 1.1 The graph of sinI 2 M

x



The PlotLabel option puts the caption on top of the plot. However, the traditional position of a

figure caption is on the bottom of the plot; this can be done with the Labeled command, as can be seen

from the second plot. For more about Labeled, see Section 3.3.1, p. 72.



7.3.2 Axes and Ticks

‡ Axes



, False g , {True, False}

* AxesOrigin Point where the axes cross; examples of values: Automatic, {0, 0}

AxesLabel Labels for the axes; examples of values: None, y, {x, None}, {x, y}

(AxesStyle Style of the axes, axes labels, tick marks, and tick labels; examples of values: {}, Thick,

Blue, Arrowheads[0.07], Directive[Thick, Blue, 12, Italic]



* Axes Whether to draw the axes; examples of values: True



cp



The point where the axes cross is AxesOrigin. Its default value is determined by an algorithm; this

method usually chooses the point {0, 0} if it is within or close to the region defined by PlotRange.

Axes labels are placed at the ends of the axes (frame labels, instead, are in the middle of the frame

edges). If the axes labels are long, consider using a frame instead of axes (see Section 7.3.3, p. 198).

The default thickness of axes and the major tick marks is AbsoluteThickness[0.25], and that for

the minor tick marks is AbsoluteThickness[0.125]. With Arrowheads, we can draw arrows at the

ends of the axes.



Chapter 7 • Graphics Options



197



8Plot@2 + Sin@xD, 8x, 1, 6<, AxesLabel Ø 8x, y
Plot@2 + Sin@xD, 8x, 1, 6<, AxesOrigin Ø 80, 0
Plot@2 + Sin@xD, 8x, 1, 6<, AxesStyle Ø Arrowheads@0.07DD<

y



3.0



3.0



2.5



: 2.0



2.0



2.5



,



2.5



1.5



,



1.0



1.5



1.5



0.5

2



3



4



5



x



6



>



2.0



1



2



3



4



5



6



2



3



4



5



‡ Defining Positions of Ticks

** Ticks Tick on the axes; simple examples of values: Automatic, None, {{p, 2p}, Automatic},

{Automatic, {-1, 0, 1}}, {{p, 2p}, {-1, 0, 1}}

TicksStyle (Ÿ6) Style of tick marks and tick labels; examples of values: {}, Blue,

Directive[Thick, Blue, 12]



The general form of the value of Ticks is {xticks, yticks}. We can define ticks on both axes or let

Mathematica choose the ticks on one of the axes. The automatic algorithm often uses appropriate ticks

but frequently also too many ticks, especially if the plots are scaled to be small (as in this book). In

particular, the minor tick marks (without labels) between the major tick marks (with labels) are often

unnecessary. A few carefully selected tick marks often suffice. Indeed, Ticks is perhaps the option I use

most often. For example,

8Plot@Sin@xD, 8x, 0, 2 p
Plot@Sin@xD, 8x, 0, 2 p<, Ticks Ø 880, p, 2 p<, 8-1, 0, 1<
1



1.0



:



0.5

1



2



3



4



5



6



,



p



2p



>



-0.5

-1.0



-1



In the second plot, we asked for only six ticks. Note, however, that we got only four tick labels: The

labels on the x and y axis at 0 were not drawn. Indeed, tick labels on the axes origin are not displayed.

‡ Defining Labels, Lengths, and Styles of Ticks

Ticks has more advanced forms, where we can define~in addition to the positions of the tick marks~



the tick labels and the length and style of the tick marks. In the next box, we give forms of a single tick

and examples in which each form is used to define two ticks on the x axis (on the y axis, the default ticks

are used).

position



Example: {{p, 2p}, Automatic}

{position, label}



Example: {{{p, a}, {2p, b}}, Automatic}

{position, label, {poslength, neglength}}



Example: {{{p, a, {0.05, 0}}, {2p, b, {0.05, 0}}}, Automatic}



198



Mathematica Navigator



{position, label, {poslength, neglength}, style}



Example: {{{p , a, {0.05, 0}, Red}, {2p, b, {0.05, 0}, Red}}, Automatic}

Often, when plotting mathematical figures, we do not want numerical tick labels but, rather, a few

symbolic labels. Then we can define, with Ticks, the positions of the labels and the labels. The next

figure is an example:

aa = 80.2, 0<; bb = 80.8, 0<; cc = 80, Exp@0.2D<;

dd = 80, Exp@0.8D<; ee = 80.2, Exp@0.2D<; ff = 80.8, Exp@0.8D<;



Plot@Exp@xD, 8x, 0, 1<, AxesOrigin Ø 80, 0<,

Ticks Ø 8880.2 , a<, 80.8, b<<, 88Exp@0.2D, c<, 8Exp@0.8D, d<<<,

Epilog Ø 8Line@8cc, ee, aa
d



c



a



b



Tick labels are, by default, written in traditional format. This may sometimes make the labels

somewhat large relative to the figure. Defining the labels as strings may be a solution:

8Plot@Sin@xD, 8x, 0, 2 p<, Ticks Ø 88p ê 2, p, 3 p ê 2, 2 p<, 8-1, 1<
Plot@Sin@xD, 8x, 0, 2 p<, Ticks Ø 888p ê 2, "pê2"<, p, 83 p ê 2, "3pê2"<, 2 p<, 8-1, 1<
1



:



1



,

p

2



p



3p



pê2



2p



p



3pê2



2p



>



2



-1



-1



7.3.3 Frame and Frame Ticks

* Frame Whether to draw a frame; examples of values: False, True, {True, True, False, False}

* FrameLabel Labels for the frame; examples of values: None, {x, y}, {"bottom", "left", "top",

"right"}

* RotateLabel Whether to rotate the labels for the vertical edges; possible values: True, False

FrameStyle Style of the frame, frame labels, frame tick marks, and frame tick labels; examples of



values: Automatic, Blue, Directive[Thick, Red, 12, Italic]

* FrameTicks Frame tick marks on the frame; simple examples of values: Automatic, None, All (on



all edges), {{0, p, 2p}, {-1, 1}, None, None}

FrameTicksStyle (Ÿ6) Style of frame tick marks and frame tick labels; examples of values: {}, Red,

Directive[Thick, Red, 12, Bold]



For most frame options (not for RotateLabel), we can define the properties separately on each of the

four edges of the frame. In the previous box, the properties were given in the form {bottom, left, top,

right}. The properties can also be given in the form {{left, right}, {bottom, top}}.

Here are some examples:



Chapter 7 • Graphics Options



199



8Plot@Sin@xD, 8x, -p ê 2, 5 p ê 2<, PlotRange Ø 8-1.3, 1.3<,

Frame Ø True, FrameLabel Ø 8x, y<, RotateLabel Ø FalseD,

Plot@Sin@xD, 8x, -p ê 2, 5 p ê 2<, AxesLabel Ø 8x, y<, PlotRange Ø 8-1.3, 1.3<,

Frame Ø True, FrameTicks Ø 880, p, 2 p<, 8-1, 0, 1<, None, None
Plot@Sin@xD, 8x, -p ê 2, 5 p ê 2<, AxesLabel Ø 8x, y<,

Ticks Ø 88p, 2 p<, 8-1, 0, 1<<, ImageSize Ø 110D êê Framed<

y



y



1.0



:



1



0.5



y



1



>



0.0



,



-0.5



x



0



,

p



-1.0

0



2



4



6



-1



8



x



0



p



2p



x



-1



2p



As the first plot shows, frame labels are placed midway on the edges (axes labels are placed at the

ends of the axes). The default value of RotateLabel is True, which means that the frame labels on the

vertical parts of the frame are rotated so that they read from bottom to top. A short label such as y looks

better and is easier to read when not rotated. If we want a frame, then the figure often looks better if

there is somewhat more space around the curve. This can be done with PlotRange.

In the second plot, we have defined our own ticks. The default is that there are tick marks on all

edges but tick labels only on the bottom and left edges. If we define our own x and y ticks, they are used

on all four edges, but with None we can remove the ticks from the edges on which we do not want them.

Frame ticks are defined in the same way as axes ticks (see Section 7.3.2, p. 196).

In the third plot, we used the Framed command instead of the Frame option; for Framed, see Section

3.3.1, p. 72.



7.3.4 Grid Lines

GridLines How the grid lines are drawn; simple examples of values: None, Automatic, {None,

Automatic}, {None, {-1,0,1}}, {{0,1,2}, {-1,0,1}}

(GridLinesStyle (Ÿ6) Style of the grid lines; examples of values: {}, Dashed,

Directive[LightGray, Dashed])



Ticks often suffice to give information about the values of the coordinates. However, if we want to

read approximate coordinates from a figure, then grid lines may help us. The value Automatic of

GridLines draws lines on the major ticks and colors them gray. For example,

Plot@Sin@xD, 8x, 0, 2 p<, Ticks Ø 88p, 2 p<, 8-1, 1<<, GridLines Ø ÒD & êü 8

Automatic,

8None, Automatic<,

88p ê 2, p, 3 p ê 2, 2 p<, 8-1, -0.5, 0.5, 1<<<

1



:



1



p



-1



2p



,



1



p



-1



2p



,



p



-1



2p



>



200



Mathematica Navigator



7.3.5 Hierarchy of Styles

For all of the components of a plot, we have options to give the components the styles we like most. We

have very general options such as BaseStyle that affect most components of a plot. We have options

such as AxesStyle that affect many components. We have special options such as FrameTicksStyle

that affect only a few components. Finally, with either the Style command or special inputs we can

control the style of single components. Let us look at the various components of a plot and how they can

be styled with options. First, the curve in a plot can be styled with PlotStyle (ColorFunction can also

be used); the BaseStyle option has no effect on the curve.

‡ Plot Label

BaseStyle affects the style of a plot label. However, if LabelStyle is used, it overrides possible

BaseStyle and so has a higher priority. Finally, if we use the Style command, it overrides possible



other options. The following examples illustrate this hierarchy of the options:



8Plot@Sin@xD, 8x, 0, 2 p<, PlotLabel Ø Sin@xD, BaseStyle Ø BlueD,

Plot@Sin@xD, 8x, 0, 2 p<,

PlotLabel Ø Sin@xD, BaseStyle Ø Blue, LabelStyle Ø GreenD,

Plot@Sin@xD, 8x, 0, 2 p<, BaseStyle Ø Blue, LabelStyle Ø Green,

PlotLabel Ø Style@Sin@xD, RedDD<



sinHxL



sinHxL



1.0

:



0.5



-0.5



sinHxL



1.0



1.0



0.5

1



2



3



4



5



-1.0



6



>



0.5



,



,

-0.5



1



2



3



4



-1.0



5



6



-0.5



1



2



3



4



5



6



-1.0



‡ Axes



Next, we consider options and commands that can be used to adjust the styles of components related to

axes. We prepare a table:

Grid@8Join@8Style@"Component", BoldD<, Style@Ò, "Input", FontFamily Ø "Courier"D & êü

8BaseStyle, LabelStyle, AxesStyle, TicksStyle, Style
8"Axes", "μ", "", "μ", "", ""<, 8"Axes labels", "μ", "μ", "μ", "", "μ"<,

8"Axes tick marks", "μ", "", "μ", "μ", ""<,

8"Axes tick labels", "μ", "μ", "μ", "μ", "μ"<<,

Dividers Ø 88False, True<, 88True<<<, Alignment Ø 88Left, Center<


Component



BaseStyle



Axes



μ



Axes labels



μ



Axes tick marks



μ



Axes tick labels



μ



LabelStyle



AxesStyle



TicksStyle



Style



μ

μ

μ



μ



μ



μ



μ



μ



μ



μ



With  we have denoted the components that each option or command can control. BaseStyle,

LabelStyle, AxesStyle, and TicksStyle are options, and Style is a command.



Chapter 7 • Graphics Options



201



The options and commands are mentioned in the table in the order of increasing priority. BaseStyle

affects all the components mentioned in the table. However, if LabelStyle is used, it has higher priority

for the labels. If AxesStyle is used, it has still higher priority over BaseStyle and LabelStyle.

TicksStyle has the highest priority for axes tick marks and tick labels. However, if we use the Style

command for axes or tick labels, it overrides possible options.



7.3.6 Primitives

‡ Adding Primitives with Prolog and Epilog



Occasionally, we may want to add some components to a plot. We may want to have clarifying text, an

important point, an arrow, or a line. Such small additions may considerably improve the quality of a

plot: They guide the eyes of the reader to important aspects of the plot. The options Prolog and Epilog

are the tools for making such additions.

(Prolog Graphics primitives to be plotted before the main plot; examples of values: {}, {Red,

PointSize[Medium], Point[{3, 2}]})

** Epilog Graphics primitives to be plotted after the main plot; examples of values: {}, {Red,

PointSize[Medium], Point[{3, 2}]}



The values of Prolog and Epilog are lists of graphics directives and primitives. Directives and

primitives were explained in Chapter 6. For easy reference, we list here the four primitives that are most

useful when using Prolog and Epilog.

Point[p] Point at p

Line[{p1, …, pn}] Line through points p1, ..., pn

Text[expr, p, q] The point q, expressed in text coordinates, of expr is at the point p

Arrow[{p1, p2}] Arrow from p1 to p2

‡ Example



We have already used some primitives with the Epilog option in a few examples; see Sections 6.2.6, p.

163 (Point, Text), 6.2.10, p. 175 (Inset), and 7.1.1, p. 183 (Point, Text, Arrow). Many more examples are

in the forthcoming chapters. In the next example, we use the primitives Point, Line, Text, and Arrow:

Plot@8Log@xD + 1, Sqrt@xD<, 8x, 0, 1.5<, PlotRange Ø 880, 1.9<, 80, 1.55<<,

ImageSize Ø 220, Ticks Ø 880.5, 1, 1.5<, 80.5, 1, 1.5<<, Epilog Ø

8Text@Log@xD + 1, 81.55, 1.42<, 8-1, 0
Text@Log@xD + 1 ã Sqrt@xD, 81.2, 0.85<, 8-1, 1
881.19, 0.82<, 81.05, 0.95<
Red, PointSize@MediumD, Point@81, 1
logHx L + 1



1.5



x

1

logHx L + 1 

0.5



0.5



1



1.5



x



Xem Thêm
Tải bản đầy đủ (.pdf) (1,135 trang)

×