Extra Credit: Use the example below to create your own program Knowlton

advertisement
Knowlton
Materials Science and Engineering
Boise State University
Text, Arrows and Legends - How to use them in you plots
Extra Credit: Use the example below to create
your own program
à We will plotting the activity of component one and two as a function of the fractional amount of 2.aα1
and a'1 α as a function of X2a2 .
To add Arrows and Text, we use the following commands:
Epilog[ ]
Arrow[ ]
Text[ ]
In[28]:=
Out[28]=
8Arrow@883 Pi ê 2, 1 ê 2<, 8Pi, 0<<D, Text@"Zero", 83 Pi ê 2, 1 ê 2<, 8−1, −1<D<
:ArrowB::
3π
2
1
,
2
>, 8π, 0<>F, TextBZero, :
3π
2
1
,
2
>, 8−1, −1<F>
Arrows Text and Legends.nb
2
In[29]:=
Clear@Ta1, X2, T, γa, ao, ∆S1aL, ∆G1aLD
∆G1aL@T_D := HTa1 − TL ∆S1aL
a1a@X1_, T_D := X1 ExpB
ao H1 − X1L2
RT
F
a1prime@X1_, T_D := a1a@X1, TD ExpB
∆G1aL@TD
RT
F
R = 8.314;
ao = 8400;
Ta1 = 1500;
∆S1aL = −9;
PlotAa1a@X1, 300D, 8X1, 0, 1<, Frame → True, GridLines → Automatic,
PlotStyle → 8RGBColor@1, 0, 0D<, FrameLabel → 9"X1 ", "aα1 "=,
PlotLabel −> " aα1 ",
Epilog → 8Arrow@88.4, .25<, 8.18, 1.7<<D, Arrow@88.65, .25<, 8.83, .9<<D,
Text@"Maximum", 8.4, .12<, 80, −1<D,
Text@"Minimum", 8.65, .12<, 80, −1<D<E
Null
aα1
1.5
Out[37]=
aα1
1.0
0.5
Maximum
Minimum
0.0
0.0
0.2
0.4
0.6
X1
In[39]:=
Here is another example using Arrows and Text using the commands:
Show[ ]
0.8
1.0
Arrows Text and Legends.nb
3
Epilog[ ]
Arrow[ ]
Text[ ]
In[40]:=
Clear@Ta1, X2, T, γa, ao, ∆S1aL, ∆G1aLD
∆G1aL@T_D := HTa1 − TL ∆S1aL
a1a@X2_, T_D := H1 − X2L ExpB
ao X22
RT
F
a1prime@X2_, T_D := a1a@X2, TD ExpB
∆G1aL@TD
RT
F
R = 8.314;
ao = 8400;
Ta1 = 1500;
∆S1aL = −9;
Plota1a = TableA
H∗Print@"T= ",T," K"D;∗L
PlotAa1a@X2, TD, 8X2, 0, 1<, PlotRange → 8−0.2, 2<, Frame → True,
GridLines → Automatic, PlotStyle → 8RGBColor@1, 0, 0D<,
FrameLabel → 9"X2 ", "aα1 "=,
PlotLabel −> " aα1 − Temp. Range: 300 − 1500 K; Increments: 100 K",
DisplayFunction → IdentityE, 8T, 300, 1500, 100<E
Show@Plota1a,
Epilog → 8Arrow@88.45, −.125<, 80, .98<<D, Hue@.7D,
Arrow@88.84, 1.76<, 8.65, .25<<D, Hue@.9D,
Text@"About 1", 8.4, −0.2<, 80, −1<D, Hue@.7D,
Text@"Inc. Temp.", 8.8, 1.8<, 80, −1<D<,
DisplayFunction −> $DisplayFunctionD
Plota1prime = TableA
H∗Print@"T= ",T," K"D;∗L
PlotAa1prime@X2, TD, 8X2, 0, 1<, PlotRange → 8−0.1, 1.05<,
Frame → True, GridLines → Automatic, PlotStyle → 8RGBColor@0, 0, 1D<,
FrameLabel → 9"X2 ", "a'1 α "=,
PlotLabel −> " a'1 α − Temp. Range: 300 − 1500 K; Increments: 100 K",
DisplayFunction → IdentityE, 8T, 100, 1500, 100<E
Show@Plota1prime,
Epilog → 8Hue@0D, Arrow@880.2, −0.05<, 8.4, .8<<D, Hue@.9D,
Text@"Inc. Temp.", 8.4, .8<, 80, −1<D<,
DisplayFunction −> $DisplayFunctionD
Arrows Text and Legends.nb
4
nge: 300 − 1500 K; Inc
2.0
1.5
Out[48]=
1.0
:
0.5
,
0.0
0.0
0.2
0.4
0.6
0.8
1.0
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
2.0
2.0
1.5
1.5
1.0
0.5
1.0
,
0.5
0.0
0.0
0.0
0.2
0.4
0.6
0.8
1.0
0.0
,
0.2
X2
0.4
0.6
0.8
1.0
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
2.0
2.0
1.5
1.5
1.0
0.5
1.0
,
0.5
0.0
0.0
0.0
0.2
0.4
0.6
0.8
1.0
0.0
,
0.2
X2
0.4
0.6
0.8
1.0
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
2.0
2.0
1.5
1.5
1.0
0.5
1.0
,
0.5
0.0
0.0
0.0
0.2
0.4
X2
0.6
0.8
1.0
0.0
,
0.2
0.4
X2
0.6
0.8
1.0
Arrows Text and Legends.nb
5
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
2.0
2.0
1.5
1.5
1.0
0.5
1.0
,
0.5
0.0
0.0
0.0
0.2
0.4
0.6
0.8
1.0
0.0
,
0.2
X2
0.4
0.6
0.8
1.0
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
2.0
2.0
1.5
1.5
1.0
0.5
1.0
,
0.5
0.0
0.0
0.0
0.2
0.4
0.6
0.8
1.0
0.0
,
0.2
X2
0.4
0.6
0.8
1.0
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
2.0
2.0
1.5
1.5
1.0
0.5
1.0
,
0.5
0.0
0.0
0.0
0.2
0.4
X2
0.6
0.8
1.0
0.0
>
0.2
0.4
X2
0.6
0.8
1.0
Arrows Text and Legends.nb
6
− Temp. Range: 300 − 1500 K; Increments: 1
2.0
Inc. Temp.
1.5
Out[49]=
a1
1.0
0.5
0.0
0.0
0.2
About 1
0.4
0.6
0.8
1.0
X2
nge: 300 − 1500 K; Inc
Out[50]=
1.0
0.8
: 0.6
0.4
0.2
0.0
,
0.0 0.2 0.4 0.6 0.8 1.0
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
1.0
0.8
0.6
0.4
0.2
0.0
1.0
0.8
, 0.6
0.4
0.2
0.0
,
0.0 0.2 0.4 0.6 0.8 1.0
0.0 0.2 0.4 0.6 0.8 1.0
X2
X2
Arrows Text and Legends.nb
7
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
1.0
0.8
0.6
0.4
0.2
0.0
1.0
0.8
, 0.6
0.4
0.2
0.0
,
0.0 0.2 0.4 0.6 0.8 1.0
0.0 0.2 0.4 0.6 0.8 1.0
X2
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
1.0
0.8
0.6
0.4
0.2
0.0
1.0
0.8
, 0.6
0.4
0.2
0.0
,
0.0 0.2 0.4 0.6 0.8 1.0
0.0 0.2 0.4 0.6 0.8 1.0
X2
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
1.0
0.8
0.6
0.4
0.2
0.0
1.0
0.8
, 0.6
0.4
0.2
0.0
,
0.0 0.2 0.4 0.6 0.8 1.0
0.0 0.2 0.4 0.6 0.8 1.0
X2
X2
Arrows Text and Legends.nb
8
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
1.0
0.8
0.6
0.4
0.2
0.0
1.0
0.8
, 0.6
0.4
0.2
0.0
,
0.0 0.2 0.4 0.6 0.8 1.0
0.0 0.2 0.4 0.6 0.8 1.0
X2
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
1.0
0.8
0.6
0.4
0.2
0.0
1.0
0.8
, 0.6
0.4
0.2
0.0
,
0.0 0.2 0.4 0.6 0.8 1.0
0.0 0.2 0.4 0.6 0.8 1.0
X2
X2
nge: 300 − 1500 K; Incnge: 300 − 1500 K; Inc
1.0
0.8
0.6
0.4
0.2
0.0
1.0
0.8
, 0.6
0.4
0.2
0.0
>
0.0 0.2 0.4 0.6 0.8 1.0
0.0 0.2 0.4 0.6 0.8 1.0
X2
X2
Arrows Text and Legends.nb
'α
1
9
− Temp. Range: 300 − 1500 K; Increments:
1.0
Inc. Temp.
0.8
Out[51]=
a'1 α
0.6
0.4
0.2
0.0
0.0
0.2
0.4
0.6
X2
Legends: They are in the graphics package and need to be loaded.
0.8
1.0
Arrows Text and Legends.nb
10
In[52]:=
<< "PlotLegends`"
Plot@8Sin@xD, Cos@xD<, 8x, −2 π, 2 π<,
PlotStyle → 8GrayLevel@0D, Dashing@80.03`<D<,
PlotLegend → 8"Sine", "Cosine"<D
1.0
0.5
−6
−4
−2
2
4
6
Out[53]=
−0.5
Sine
−1.0
Cosine
Legends : Further discriptions of legends are found below with an example.
option name
default value
LegendSpacing
Automatic
space around each key box in the legend, expressed as the ratio of the
LegendTextSpace
Automatic
space allocated next to the key boxes for text, expressed as in Legen
LegendLabelSpace
Automatic
space allocated for the legend label, as in LegendSpacing
LegendBorderSpace
Automatic
space allocated around the entire legend, as in LegendSpacing
LegendBorder
Automatic
style for a border line around the legend box, can only be used if Leg
LegendBackground
Automatic
style for a background to the legend, can only be used if LegendSha
ShadowBackground
GrayLevel@0D
color for the legend’s drop-shadow
Arrows Text and Legends.nb
In[54]:=
11
<< "PlotLegends`"
Plot@8Sin@xD, Cos@xD<, 8x, 0, 2 π<,
PlotStyle → 8GrayLevel@0D, 8GrayLevel@0D, Dashing@80.03`<D<<,
PlotLegend → 8"sin", "cos"<, LegendPosition → 80.5`, −0.7`<,
LegendTextSpace → 0.5`, LegendLabel → "Trig Funcs",
LegendLabelSpace → 0.5`, LegendOrientation → Horizontal,
LegendBackground → GrayLevel@0.5`D, LegendShadow → 80.1`, −0.2`<,
Background → GrayLevel@0.8`DD
1.0
0.5
1
2
3
4
5
Trig 6Funcs
Out[55]=
−0.5
−1.0
sin
cos
Download