Professional Documents
Culture Documents
Examples of Two-And Three-Dimensional Graphics in Smath Studio - by Gilberto E. Urroz, October 2010
Examples of Two-And Three-Dimensional Graphics in Smath Studio - by Gilberto E. Urroz, October 2010
Examples of Two-And Three-Dimensional Graphics in Smath Studio - by Gilberto E. Urroz, October 2010
sm
Basic__commands
__using__the__"Insert"
__menu:
To insert a two-dimensional (2D) graph, use: Insert > Plot > 2D
To insert a three-dimensional (3D) graph, use: Insert > Plot > 3D
Using__icons__in__the__"Functions"
__palette:
Click on the "2D" or "3D" icon in the palette
to insert a 2D or 3D graph: -> -> -> -> -> -> -> ->
1 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
12 y
1 - Click on point in your worksheet
where you want to set the upper 8
left corner of graph
2 - Click on the "2D" icon in the 4
"Functions" palette or use the
"Insert > Graph > 2D" menu option 0 x
3 - Click on the placeholder below the
graph
-4
4 - Click on the "Multiple values"
icon, then type the functions to
be plotted in each placeholder in -8
the open brace
-16 -8 0 8 16
12
In this example we plot the sin x
functions: "sin(x)" and "cos(x)", cos x
then click somewhere in the
worksheet outside of the graph.
Adding
__more__entries__to__the__"Multiple
__values"__icon:
The "Multiple values" icon produces two entries by default.
However, you can insert more entries by following this
procedure:
2 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
(1) Click somewhere in the worksheet, then click on the
"Multiple value" icon in the "Functions" palette,
to produce the "Multiple values" brace as shown.
This figure shows the default case of "Multiple
values," i.e., a brace with two entries.
(3) Place the mouse over the holder until the double
arrow icon shows up ...
1 - blue 2 - red
3 - black 4 - magenta, etc.
3 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
1 - Click on point in your worksheet
where you want to set the upper
left corner of graph
z
2 - Click on the "3D" icon in the
"Functions" palette or use the 6
"Insert > Graph > 3D" menu option 4
3 - Click on the placeholder below the 2
graph
4 - Click on the "Multiple values" 20 2 4 6 x
64
y
icon in the "Function" palette
5 - Add one more entry to the "Multiple
values" brace.
Icons__in__the__"Plot"
__palette: -> -> -> -> -> -> ->
(1) Rotate: Rotate a 3D graph only
(2) Scale:(see instructions below)
(3) Move: drag graph up or down, left or right
(4) Graph by points: show points instead of lines
(5) Graph by lines: show lines (default)
(6) Refresh: restore to original version of graph
__of__"Scale"__in__a__2D__graph:
Detalles
* ZOOM IN or OUT: Click on the "Scale" icon, icon (2), then click on
the graph (also for 3D plots):
- ZOOM IN: Drag the mouse inwards, towards the origin, to decrease
size of axes divisions
- ZOOM OUT: Drag the mouse outwards, away from the origin, to increase
size of axis divisions
* ZOOM IN or OUT on the x-axis only: Click on the "Scale" icon, click
on the graph, hold the [SHIFT] key, then:
- ZOOM IN X-AXIS: roll mouse wheel up
- ZOOM OUT X-AXIS: roll mouse wheel down
* ZOOM IN or OUT on the y-axis only: Click on the "Scale" icon, click
on the graph, hold the [CTRL] key, then:
- ZOOM IN Y-AXIS: roll mouse wheel up
- ZOOM OUT Y-AXIS: roll mouse wheel down
4 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
64 y (2) y
2
48
0 x
32 -2
-8 -4 0 4 8
16 sin x
(3) y
0 x 8
-16 4
-32 0 x
-4
-48
-8
-64 0 -16 -8 0 8 1
sin x sin x
4
2
20 2 4 6 x
64
y
z
6 sin x cos y
4
2
z
20 2 4 6
64 6
y
4
2
20 2 4 6 x
64
y
5 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
12 y y
4
8
4
0 x
-4
0 x
-8
-4
-12
-8
-16 -8 0 8 16 -16-8 0 8 16 24
12
sin x sin x
z
6
z
4
6
2
4
42 0 2 4 6 x
2 y6
20 2 4 6 x
64
y
Detalles
__of__"Scale"__in__a__2D__graph__(repeated):
6 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
* ZOOM IN or OUT: Click on the "Scale" icon, icon (2), then click on
the graph (also for 3D plots):
- ZOOM IN: Drag the mouse inwards, towards the origin, to decrease
size of axes divisions
- ZOOM OUT: Drag the mouse outwards, away from the origin, to increase
size of axis divisions
* ZOOM IN or OUT on the x-axis only: Click on the "Scale" icon, click
on the graph, hold the [SHIFT] key, then:
- ZOOM IN X-AXIS: roll mouse wheel up
- ZOOM OUT X-AXIS: roll mouse wheel down
* ZOOM IN or OUT on the y-axis only: Click on the "Scale" icon, click
on the graph, hold the [CTRL] key, then:
- ZOOM IN Y-AXIS: roll mouse wheel up
- ZOOM OUT Y-AXIS: roll mouse wheel down
0 x
-4
y
-8
1
-2 -1 0 1 2
12
sin x 0.5
To zoom the y-axis only: ---->
1 - Click on "Scale" in the "Plot" palette 0 x
2 - Click on the graph window
3 - Hold down the "Control" key
4 - Roll the mouse wheel up or down -0.5
-1
-16 -8 0 8 16
sin x
7 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
y
0.75
0.5
0.25
<--- You can zoom both axes by zooming one
axis at a time. In this case, I zoomed
0 x
the x axis first, and then the y axis.
-0.25
-0.5
-0.75
-6 -4 -2 0 2 4 6
sin x
z z
6 2
4
1
2
20 2 4 6 x 0 1 2 x
64 21
y y
sin x y sin x y
cos x y cos x y
Examples
__of__other__types__of__graphs
__in__2-D
The following examples show other ways to produce 2D graphics. Data for
a graph y = f(x) can be generated by using a vector of values of x, then
generating a vector of values of y. The two vectors are then put
together into a matrix, whose name is used in the 2D graph placeholder
instead of f(x).
8 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
Fill out y vector using a for loop. Click "for"
for k 1 .. n in the "Programming" palette, then use:
2 range 1 , n
y sin x sin 2 x
k k k
Use sub-indices, e.g., y [ k ... etc.
1.5
< --- The graph was zoomed in and the axes
1 moved by using the following procedures:
y
Using the sparse data in matrix M we reproduce
2
the graph above, but then we selected the
"Graph by points" option in the "Plot" palette
1.5 to produce the graph shown to the left.
0 x
-0.5
-4 -2 0 2 4
-1
M
x , .. n length x n 41
20
for k 1 .. n
y sin x
k k
M augment x , y
9 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
12 y y
1
8
0.5
4
0 x 0 x
-4
-0.5
-8
-1
-16 -8 0 8 16 -8 -6 -4 -2 0 2 4 6 8
12
M M
cos x cos x
t , .. Define the vector of the parameter t
50
n length t Determine length of vector t = n
for k 1 .. n
Calculate vectors of x = x(t) and
x sin 3 t y = y(t)
k k
y 2 cos 2 t
k k
Produce matrix of (x,y) and plot it
M augment x , y
y y
2 2
1 1
0 x 0 x
-1 -1
-2 -2
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
M M
10 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
Polar plots are similar to parametric plots. In polar plots the
independent variable is the angle , and the dependent variable
is the radial position r, i.e., r = f(). To produce the plot
the (x,y) coordinates are calculated using x = r*cos() and
y = r*sin() as illustrated below.
0, .. 2 Generate vector of between 0 and 2
50
n length Determine lenght of vector
for k 1 .. n Generate values of r = f()
r 2 1 2 sin
k k
for k 1 .. n
Generate coordinates:
xx r cos
k k k
yy r sin x = r cos()
k k k y = r sin()
y y
6 6
5 5
4 4
3 3
2 2
1 1
0 x 0 x
-4 -2 0 2 4 -4 -2 0 2 4
-1 -1
P P
11 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
for k 1 .. n Generate vectors x, y, and z using a "for" loop
x sin t
k k
y cos t
k k
t
k
z
k 2
M augment x , y , z
Build matrix M with coordinates (x,y,z)
z
6
4
2
20 2 4 6 x
64
y
Using graphics and zooming the intersection we estimate the solution to be close to
x = 1.80
16 4.375
12 4.25
8 4.125
4 4
0 x 3.875
-4 -2 0 2 4 1.625 1.6875 1.75 1.8125 1.875
-4
f x f x
g x g x
2 3
The exact solution can be found using: solve x 1 x 2 x 5, x 1.78
12 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
Solution: Write out all the given data without units, but using the
========= proper set of units for the English System:
6
L 1000 (ft) D 0.15 (ft) ee 5 10 (ft) z 6 (ft)
5
1.2 10 (ft^2/s) g 32.2 (m/s^2) Km 0.5 1.0 6.0 , i.e., Km 7.5
2 [2]
The pump equation is: hP a b Q c Q
2
8 Q ee 4 Q L 2
hP1 Q z Km fSJ , hP2 Q a b Q c Q
2 4 D D D
g D
13 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
16 y
14
12
10
0 x
-2 0 0.015625 0.03125 0.046875 0.0625 0.07
hP1 x
hP2 x
2
solve hP1 Q hP2 Q , Q , 0 , 1 3.01 10
z
z8
6
6
4
4
2 2
20 2 4 6 x 02 4 6 8x
64 2
y 4
6
y8
x y x y
Use the option "3D" in the "Functions" palette, Use the "Rotate" option in the "Plot" palette
and enter the function f(x,y) in the place- to change the surface view.
holder. The result is a 3D surface, in this
case, a plane. The original plot is shown
above.
14 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
z8 z8
6 6
4 4
2 2
02 4 6 8x 02 4 6 8x
2 2
4 4
6 6
y8 y8
x y x y
This figure uses the option "Graph by This figure uses the option "Graph by
Lines" in the "Plot" palette (default). Points" in the "Plot" palette.
z
27
z
18
6
4 9
2
9 0 9 x
18 27
18
20
2 4 6 x
4 y27
6
y
x y x 2 y
Note: Use the "Refresh" option in the "Plot" menu to recover the original version of any plot.
15 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
z z
6 6
4 4
2 2
02 2 4 6 x 20 2 4 6 x
46 64
y
y
sin x 2 2
5 x y
z
8
z 6
6
4
4
2 2
x6420 2
02 4 6 8x
2 4
4 6
6 y8
y
x y x y
x y
The type of 3D graphs of surfaces produced by SMath Studio are referred to as wireframe plots.
EXAMPLE 16 - The following examples show more than one surface plot together in 3D:
z
8
6
z8
4 6
2 4
8x
6420 2 4 6 y8 2
0 2 4 6 8x
2
4
6
y8
x y
x y
x y
x y
x 2 y
16 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
z
9 z8
6 6
4
3
2
6 3
0 3 6 9 x 0 2 4 6 8x
2
y9 4
6
y8
2 2 sin x
5 x y
sin y
2 2
x y
y8
x y
M
for k 1 .. n for k 1 .. n
x1 1 5 t x2 1 3 t
k k k k
y1 1 4 t y2 1 t
k k k k
z1 1 8 t z2 t
k k k k
P augment x1 , y1 , z1 Q augment x2 , y2 , z2
17 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
z z
6 6
4 4
2 2
20 2 4 6 x 20 2 4 6 x
64 64
y y
P Q
Individual plots of curves given by matrices P and Q.
z
6
4 <--- Join plot of
2 lines given
by matrices
20 2 4 6 x
64 P and Q
y
P
Q
Plot__specifications
__using__SMath__Studio
__0.89__-__Release__8
SMath Studio 0.89 - Release 8 includes the ability of specifiying
four different types of symbols for the graphs, modifying the
size of the symbols, and select the color of the symbol. This is
accomplished by building a matrix that includes the coordinates
(x,y), the character, its size, and the color, in that order.
18 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
You can write them in lower case lettes , as shown above, or all in upper
case letters, or combinations of upper and lower case letters. For example,
you could write in your color specification "darkblue", "DARKBLUE", or
"DarkBlue", and the result would be the same. Additionally, you can have
spaces in the color specification which will be ignored by SMath Studio in
producing the output to the graphic canvas. For example, you can write
"Dark Blue", and it will be interpreted as "darkblue".
19 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
y 12 y
8 8
-4 -4
-8 -8
-16 -8 0 8 16 -16 -8 0 8 16
ch01 12
ch02
12 y
Gilberto E. Urroz
8
-4
Using SMath Studio
-8
-16 Utah
-8 State
0 University
8 16
12
ch03
A__program__to__plot__single
__data__sets__with__different
__symbols,
__sizes,
__and__colors
The following program was made available by Prof. Radovan Omorjan in the
SMath Studio Forum. The program takes vectors of values (x,y) and creates
a plot matrix for the data using a specified character (char), size, and
color. This program operates only in SMath Studio version 0.89 release 8,
and later. The expression for the program, or function, is:
20 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
x 0 , 0.5 .. 10 n length x n 21
for k 1 .. n
y sin x
k k
1.5y 1.5 y
1 1
0.5 0.5
0 x 0 x
-0.5 -0.5
-1 -1
0 2 4 6 8 10 0 2 4 6 8 10
plot1 plot2
y 1.5 y
1.5
1 1
0.5 0.5
0 x 0 x
-0.5 -0.5
-1 -1
-1.5 -1.5
0 2 4 6 8 0 2 4 6 8 10
plot3 plot4
x 0 , 0.5 .. 10 n length x n 21
21 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
for k 1 .. n
y sin x
k k
z sin 2 x
k k
r cos 3 x
k k
Some plots based on the matrices, and the original functions used to produce the
matrix data, are shown next:
y y
1.5
1.5
1
1
0.5
0.5
0 x 0 x
-0.5
-0.5
-1
-1
-1.5
-1.5 0 2 4 6 8 10 -2 0 2 4 6 8 10
2
MYZ MZR
y y
1.5
1
1
0.5
0.5
0 x 0 x
-0.5
-0.5
-1
-1
-1.5
0 2 4 6 8 10 0 2 4 6 8 10
MYR MYZR
22 / 23
20 Oct 2010 07:26:36 - GraphsBasics10152010_ForPrinting.sm
y y
1
1
0.5
0.5
0 x 0 x
-0.5
-0.5
-1
-1
-2 0 2 4 6 8 10 12 0 2 4 6 8 10
-1 5
MYZ MYZ
sin x sin x
sin 2 x
23 / 23