# Plot Functions

## Content

The plot functions of EMT.

## Reset

```white:=0;
black:=1;
red:=2;
green:=3;
blue:=4;
cyan:=5;
olive:=6;
lightgray:=7;
gray:=8;
darkgray:=9;
orange:=10;
```
```turquoise:=12;
lightblue:=13;
lightorange:=14;
yellow:=15;
```
```ResetEpsilon:=epsilon();
ResetView:=_view();
```
```function reset
```
```  Resets many internal settings.

This function resets the default settings for colors, line width,
the default view, and other basic settings for Euler graphics. It
does also unclip the window, and release the hold flag.

Moreover, the function resets the default format to long, and
restores the default epsilon.

See:   restart (Euler Core),   restart (Maxima Documentation)
```

## Plots in 2D

plot2d() handles all plotting in the plane. This includes plots of functions of one variable, implicit plots of functions of two variables, plots of curves and polygons in the plane, data and bar plots of two vectors, or clouds of points in the plane.

plot3d() handles all plotting in 3D stereographic view. This includes plots of functions of two variables, implicit plots of functions of three variables, plots of surfaces, bar plots of matrices, or clouds of points in the space. There is an option to view the plot in anaglyph mode with red/cyan glasses.

For a demonstration of 2D plots in Euler, see the following introduction notebook.

```function plot2d (xv,yv=none,btest=none,
a=none,b=2,c=none,d=2,
xmin=none, xmax=1, r=none, n=none, logplot=0,
grid=none, frame=none, framecolor=none,
square=0, color=none, thickness=1, style=none, auto=1, add=0,
bar=0, histogram=0, distribution=0, even=0, steps=0,
hue=0, level=none, contour=0, nc=defaultnc,
filled=0, fillcolor=none, outline=1,
title="",xl=none,yl=none,
maps=0,
contourcolor=none, contourwidth=1,
ticks=1, margin=none, clipping=true,
cx=0, cy=0,
insimg=0, spectral=0,
cgrid=none, vertical=1, smaller=none,
dl=0,
niveau=none, levels=none)
```
```  Multipurpose plot function for plots in the plane.

Multi-Purpose function for 2D plots. For an overview of Graphics
and Plots in EMT, double click the following link.

See:   Plots (Overview)

This function can do plots of functions of one variables, data
plots, curves in the plane, bar plots, grids of complex numbers, and
implicit plots of functions of two variables.

Parameters

x,y :
Equations, functions or data vectors.
One equation is a simple function plot. Two equations is a curve.
In this case xmin,xmax need to be used, because a,b,c,d determine
the plot area in this case. If x and y are row vectors, the points
will be used for the plot. If x and y are matrices, a plot for each
rwo will be produced. For implicit plots, x must be an expression
in x and y. xmin,xmax : Range for curve plots with two functions.
a,b,c,d :
Plot area (default a=-2,b=2)
r :
If r is set, then a=cx-r, b=cx+r, c=cy-r, d=cy+r,
r can be a vector [rx,ry] or a vector [rx1,rx2,ry1,ry2].
xmin,xmax :
Range of the parameter for curves.
auto :
Determine y-range automatically (default is >auto).
square :
If true, try to keep square x-y-ranges.
n :
Number of intervals (default is adaptive).
Use adaptive plots (n is the minimal number of steps).
This is used by default. In steep regions, more plot points
will be generated, i.e., a finer grid.
grid :
0 = no grid and labels,
1 = axis only,
2 = normal grid (see below for the number of grid lines)
3 = inside axis
4 = no grid
5 = full grid including margin
6 = ticks at the frame
7 = axis only
8 = axis only, sub-ticks
frame:
Draw a frame around the plot (default >frame)
framecolor:
Color of the frame and the grid.
margin :
Number between 0 and 0.4 for the margin around the plot.

color :
Color of curves. If this is a vector of colors, it will be used
for each row of a matrix of plots. In the case of point plots, it
should be a column vector. If a row vector or a full matrix of
colors is used for point plots, it will be used for each data
point.

thickness :
Line thickness for curves This value can be smaller than 1 for
very thin lines.

style :
Plot style for lines, markers, and fills.
For points use
"[]", "<>", ".", "..", "...",
"*", "+", "|", "-", "o"
"[]#", "<>#", "o#" (filled shapes)
"[]w", "<>w", "ow" (non-transparent)
For lines use
"-", "--", "-.", ".", ".-.", "-.-", "->"
For filled polygons or bar plots use
"#", "#O", "O", "/", "\", "\/",
"+", "|", "-", "t"

points :
Plot single points instead of line segments (>points).
If true, plots line segments and points (>addpoints).

Add the plot to the existing plot. This will not redraw the grid
or the frame, just add another plot. It will use the same range
values.

user :
Enable user interaction for functions (>user) for plots of
functions.
left, right : move the interval
+/- : enlarge the viewpoint.
mouse clicks : select region of interest.
space : end interaction.
delta :
Step size for user interaction.

bar :
Bar plot (x are the interval bounds, y the interval values) (>bar).
The package stat.e contains column plots too.
histogram :
Plots the frequencies of x in n subintervals. x is a vector of
random values.
distribution :
Plots the distribution of x with n subintervals.
even :
Use integer values for automatic histograms.

steps :
Plots the function as a step function (steps=1,2).

level :
Plot level lines of an implicit function of two variables.
If the level value is a 2xn matrix, ranges of levels will be drawn
in the color using the given fill style. If outline is true, it
will be drawn in the contour color. Using this feature, regions of
f(x,y) can be marked. Instead of a 2xn matrix, a simple vector of
levels can be used and dl can be set to the thickness of these
levels.
outline :
Draws boundary of level ranges.
hue :
Aadd hue color to the level plot to indicate the function
value
contour :
Use level plot with automatic levels.
nc :
Number of automatic level lines
contourcolor :
Color of contour lines
contourwidth :
Width of contour lines

title :
Plot title (default "").
This can be used to describe the plot. The title will appear
above the plot. Moreover, a label for the x and y axis can be added
with xl="string" or yl="string". Other labels can be added with the
functions label() or labelbox(). The title can be a unicode string
or an image of a Latex formula.

xl, yl :
Labels for the x- and y-axis
smaller :
If >0, there will be more space to the left for labels.

vertical :
Turns vertical labels on or off. This changes the global variable
verticallabels locally for one plot. The value 1 sets only vertical
text, the value 2 uses vertical numerical labels on the y axis.

filled :
Fill the plot of a curve. A curve is simply a plot with non-increasing
x values. The fill style is determined by the parameter style.
fillcolor :
Fill color for bar and filled curves
outline :
Boundary for filled polygons

logplot : set logarithmic plots
1 = logplot in y,
2 = logplot in xy,
3 = logplot in x

own :
A string, which points to an own plot routine. With >user, you get
the same user interaction as in plot2d. The range will be set
before each call to your function.

maps :
Map expressions (0 is faster), functions are always mapped.

clipping :
Sets clipping (default is true).

cgrid :
Determines the number of grid lines for plots of complex grids.
Should be a divisor of the the matrix size minus 1 (number of
subintervals). cgrid can be a vector [cx,cy].

Typical Examples:

>plot2d("x^3-x",-1,2,title="y=x^3-x",yl="y",xl="x");
>plot2d("x^3-x",a=0,b=2,c=-1,d=2,grid=3,<frame);
>plot2d({{"x^3-a*x",a=1}},>user,title="Press any key!");

>function f(x) &= x^x;
>plot2d(f,r=1,cx=1,cy=1,color=blue,thickness=2);

>x=linspace(0,2pi,1000);
>plot2d(sin(5x),cos(7x));
>plot2d(sin(x),cos(x)*0.5,r=1,>filled,style="/");

>k=0:10;
>plot2d(k,bin(10,k),>bar);

>plot2d(normal(1,1000),>distribution,style="O");
>plot2d("qnormal",0,5;2.5,0.5,>filled);

>plot2d("x^2",0,1,steps=1,color=red,n=10);

>plot2d("x^3-y^2",>contour,>hue,>spectral);

For more information refer to the overview in Plots or the tutorials.

See:   Plots (Overview),   plot3d (Plot Functions),   plot3d (Maxima Documentation),   label (Plot Functions),   label (Maxima Documentation),   rgb (Plot Functions),   yaxis (Plot Functions),   yaxis (Maxima Documentation),   xgrid (Plot Functions),   xlabel (Plot Functions),   xlabel (Maxima Documentation),   call (Euler Core)
```

## Plots in 3D

```function plot3d (x, y=none, z=none,
xmin=none, xmax=none, ymin=-1, ymax=1, n=60,
a=none, b=none, c=none, d=none, r=none,
scale=1, fscale=-1, frame=1,
angle=none, height=none, zoom=none,
distance=none, view=none,
center=none, cx=0, cy=0, cz=0,
xlabel="x", ylabel="y", zlabel="z",
sframe=none, grid=none,
polar=false, sliced=false, disconnect=none,
hue=false, light=[2,3,4], amb=0.1, max=0.9,
spectral=false, xhue=0, yhue=0, zhue=0, hues=none,
color=none, framecolor=none, transparent=0,
anaglyph=0,	user=0, duser=0.1,
wire=false, wirecolor=none, points=false, style=".",
lines=false, contour=false, rotate=false, title="",
bar=false, own=false,
level=none, dl=0, nc=defaultnc, values=none, contourcolor=none, contourwidth=1,
implicit=false, zmin=-1, zmax=-1,
maps=false, insimg=false,
cp=false, cpcolor=none, cplevel=none, cpdelta=0.05,
levels=none, niveau=none,
linewidth=none, fillcolor=none,
fullwindow=true,
zscale=false,zlim=none)
```
```  General function for 3D plots.

Multi-Purpose function for 3D plots. For an overview of Graphics
and Plots in EMT, double click the following link.

See:   Plots (Overview)

This function can plot 3D plots with graphs of functions of two
variables, parameterized surfaces, space curves, clouds of points,
solutions of an equation of three variables. All 3D plots can be
shown as anaglyphs.

Parameters

x : expression in x and y
x,y,z : matrices of the coordinates of a surface
x,y,z : expressions in x and y for a parametric surface
x,y,z : expressions in x to plot a space curve

xmin,xmax,ymin,ymax :
x,y bounds for expressions
a,b,c,d :
Alternative for xmin,xmax,ymin,ymax.
r :
Can be used instead of xmin,xmax,ymin,ymax.
r can be a vector [rx,ry] or [rx,ry,rz].
r is also used in polar plots.
cx, cy, cr :
Center of plot, if r is used.

n :
Accuracy, i.e. the number of sub-intervals. If n is a
vector, it is used in each direction.
grid :
Determines the grid lines. For plots of functions, n can
be larger than grid, but it will be adjusted to be
a multiple of grid. For x-y-z-plots the user has to
take care of this. A 1x2 vector can be used for each
direction.

scale :
Scale plot to this size (0 = no scaling, 1 = default).
If scale is a 1x3 vector, it will scale in each direction.
Function plots will be auot-scaled. But x-y-z-plots often
need to be scaled in some direction.

fscale :
Scales the z-values for a function to this range
(0=no, -1=auto)

zscale :
Scales data matrices in z-direction. Can be combined with
scale=[sx,sy,sz]. The value of zscale is used as a scaling
factor. It should be between 0.1 and 1.

wire : Generates a wire plot (>wire).
polar : Generats a polar plot (>polar)
points : Plots a cloud of points. (>points)

sliced :
Plot a sliced version (0=no, 1=x-direction, 2=y-direction).
hue :
Compute shading using a light source.
light, amb, max :
Controls the shading setting the light point, ambient and
maximum.
contour :
Show thick level lines (with automatic levels).
levels:
If true, set thin level lines (automatic levels).
level :
Level lines (1xn vector) or level ranges (2xn vector).
dl :
Expand level lines (1xn) to level ranges (2xn) with this
thickness.

spectral :
Use spectral colors instead of monochrome hue.
There are spectral schemes from spectral=1 (>spectral)
to spectral=9. >spectral defaults to >zhue.
In fact, this is equivalent to color=-2 to color=-10.

xhue,yhue,zhue :
Use these coordinates instead of a light source.
hues :
A matrix of hue values from 0 to 1 for the shading
for x-y-z-plots. The matrix must have a size compatible
to x,y,z.

values :
Values to be used for contour plots (default: z-values)
in x-y-z-plots with hue. The levels and the limits are
computedusing these values. The matrix must be compatible
to the matrices x, y, z.
contourcolor :
Color of contour lines.
contourwidth :
Width of contour lines.
fillcolor :
Fill color for 3d surfaces with no hue.

limits :
Clip the plot outside an interval of values.
This is a 1x2 matrix [min,max]. The values taken from
the parameter values (by default the z-values). In case
of a function plot, you may want to set zlim to restrict
the frame (a 1x2 matrix too).

user :
The user can turn the plot around with the keyboard.
left,right,up,down turns the plot. +,- zooms the plot.
Space resets the plot. Return ends the user interaction.
The key a generates an anaglyph plot. The key l toggles
the movement of the light source for hue plots. The key
c moves the plot up, down, left or right.
duser :
Controls the accuracy of the user action (default 0.1).

lines :
Plot a line in space given by three expressions in x.
Use xmin, xmax for the bounds of the parameter x.

rotate :
Rotation plot of a funciton in one expression in x.
Use xmin, xmax for the bounds of the parameter x.

anaglyph :
Generate an anaglyph 3d plot (>anaglyph). This plot
needs red-dyan glasses to be viewed properly.

viewangle :
The default angle of view, rotated around the z-axis.
The value is in radians, but 10� etc. can be used.
0 is in the direction of the x-axis.
viewheight :
The height of view above the x-y-axis (-pi/2 to pi/2).
Use -90� to 90�.
zoom :
The zoom of view. Default is around 2.6.
distance :
Distance of view. Default is 5. Note that the plot is
usually scaled unless <scale is set. The distance applies
to the scaled plot.
view :
The complete view, a 1x4 vector conaining distance, zoom,
viewangle, viewheight.
center :
This vector moves the center of the plot. It is necessary
if the plot should not be centered in (0,0,0) automatically.
For x-y-z-plots with an own frame, it is essential.

implicit :
Creates an implict plots of f(x,y,z)=0. The plot consists of
grid lines on the surface cut by planes parallel to an axis.
Use 0=off, 1=x, 2=y, 4=z to select the axis. These values can

style :
Plot style for markers (see plot2d for available styles).

maps :
Expressions should be mapped (faster, if 0). Functions
are always mapped.

color :
Color for markers and for shaded surfaces
wirecolor :
Color for wire plots

frame :
If 0 (<frame), no frame is drawn. If this is a vector, it must
be of the form [xmin,xmax,ymin,ymax,zmin,zmax]. Make sure that
the plot fits into the frame. The vector is only applied to
x-y-z-plots, not to plot of functions.
framecolor :
The color of the 3D frame.
sframe :
Sets the ranges for the values on the frame. This is a vector of the
same form as frame. Use this, if the true ranges are different from
the values.

cp :
Draws a contour plane below the plot (>cp).
cpcolor :
The color for the contour plane.
cplevel :
The level lines for the contour plane.
cpdelta :
The distance (relative) to the z-range of the contour plane.

Typical Examples:

>plot3d("x*y",r=1,title="z=x*y"):
>plot3d("x*y^2",>user,r=1,title="Press cursor keys or return!"):
>plot3d("x^2*y^3",r=0.9,zlabel="x^2*y^3",angle=30�,height=20�,zoom=3, ...
>  >cp,cplevel="thin",cpcolor=green):
>plot3d("x^2+y^3",angle=0�,>contour,>spectral):
>plot3d("x^y-y^x",a=0,b=4,c=0,d=4,angle=40�,level=0, ...
>  contourwidth=4,contourcolor=red,n=100):
>plot3d("x^2+y^2",>wire,>anaglyph,title="Use Red/Cyan Glasses!",n=10):
>plot3d("x^3+y^2",0,2,0,10,scale=[5,1,2],zoom=3.2,grid=10,>transparent):
>plot3d("x^2+y^3+sin(z)^2-1",r=pi,implicit=4,zoom=3):
>x=-1:0.05:1; y=x'; plot3d(x,x*y^2,y,>hue,angle=20�):
>h=x^2+y^2; ...
>plot3d(x,y,(y-x)/2,level=-2:0.1:2,values=h,hues=h/2,>spectral):
>X=normal(3,1000); plot3d(X[1],X[2],X[3],>points,zoom=3,>user):
>Y=cumsum(X); plot3d(Y[1],Y[2],Y[3],>wire,>user):
>t=linspace(0,2,1000);  ...
>plot3d(sin(2pi*t),cos(2pi*t),t,>wire,>anaglyph):
>plot3d("min(1/(x^2+y^2),3)",r=1.5,>hue,limits=[0,2.9]):

For more information see the overview in Plots or refer to the tutorials.

See:   Plots (Overview),   plot2d (Plot Functions),   plot2d (Maxima Documentation),   call (Euler Core)
```

## Support functions for Plots

It should not be necessary to call these functions directly, unless a special effect is needed. You can use plot2d or plot3d instead. Have a look at the tutorials.

There are also some core functions, which are not explained here. Look at the following documentation, if you need those.

Moreover, some of the following functions link to core functions for further details.

```function overwrite window
```
```  window(c1,r1,c2,r2) sets a plotting window.

The coordinates must be screen coordinates.
window() returns the active window coordinates.

See:   coordinates (Euler Core)
```
```function squarewindow ()
```
```  Make the plot window square.

This function is called by fullwindow() and shrinkwindow() with the
>square parameter. It makes the window square in screen coordinates
by retracting its larger dimension towards the middle of the
window.

See:   fullwindow (Plot Functions),   shrinkwindow (Plot Functions)
```
```function fullwindow (title=false, square=true)
```
```  Takes the full size for the plots

The plot window is the part that is actually used by plot2d and
plot3d for graphs. For plot2d() it does not include the labels, the

See:   allwindow (Plot Functions),   shrinkwindow (Plot Functions),   reset (Plot Functions),   reset (Maxima Documentation)
```
```function shrinkwindow (smaller=false, square=true)
```
```  shrinkwindow() shrinks the window to allow labels.

This sets the default plot window, leaving place for the labels at
the left and the button, and for the title line. For more space,
use fullwindow(). If you need larger labels at the y-axis, set
>smaller. If you want to have an exact 1:1 square plot use >square.

See:   fullwindow (Plot Functions),   reset (Plot Functions),   reset (Maxima Documentation)
```
```function allwindow
```
```  Takes all of the window for the plot

See:   fullwindow (Plot Functions),   shrinkwindow (Plot Functions)
```
```function overwrite setplot
```
```  setplot(xmin xmax ymin ymax) sets the plot coordinates.

Also setplot([xmin,xmax,ymin,ymax]).

setplot() resets it.
```
```function overwrite aspect (w:positive number=none,
h:positive number=1, reset=true)
```
```  Set the window aspect to w times h.

This function reduces the plot window to a new window with
proportions w times h. The font size remains the same as in the
full window.

If an aspect with larger width is active, insimg() (or the :) will
insert only the active portion of the window.

Without parameters, the function resets to the default window.

Returns the current window ratio.

Example:

>aspect(2);
>plot2d("sin(x)",0,2pi):
aspect();

See:   insimg (Euler Core),   insimg (Plot Functions)
```
```function unclip
```
```  Clips to the complete graphics screen

```
```function overwrite clip
```
```  clip(c1,r1,c2,r2) sets the clipping window.

The coordinates must be screen coordinates. clip() returns the
active clipping window coordinates. The function can also be used
with a 1x4 vector. It returns a 1x4 vector. Calls the built-in
function _clip().

See:   unclip (Plot Functions)
```
```function clipmore (x,more=0)
```
```  Sets the clipping window.

The coordinates must be screen coordinates. There is some extra
space around the area x clip() returns the active clipping window
coordinates.

```
```function overwrite args toscreen (x,y=none)
```
```  Convert the x-y-coordinates to screen coordinates

Plot coordinates are generated by the last plot or by setplot().
They reflect the x-y-positions of the points in the plot. Screen
coordinates range from 0..1024 (even for non-quadratic aspect
rations).

The function calls the built-in function _toscreen([x,y]), which
accepts and returns 1x2 vectors. With only one parameter, the
function calls _toscreen() directly assuming a 1x2 vector. With two
parameters, it assumes x and y separately, and returns {c,r}.

See:   aspect (Euler Core),   aspect (Plot Functions),   setplot (Euler Core),   setplot (Plot Functions)
```
```function overwrite args fromscreen (c,r=none)
```
```  Convert the screen coordinates v[1],v[2] to x-y-coordinates.

fromscreen(c,r) : column and row in screen coordinates,
returns {x,y}
[c,r] : use function with vectors, returns [x,y]

Calls the built-in function _fromscreen(). For more explanation
about coordinates see the function toscreen().

See:   toscreen (Plot Functions)
```
```function label (text, x:number, y:number, offset=15, ..
color=none, ypos="l", xpos="r", pos=none,
scale=1/3, tcolor=0)
```
```  Label the x-y-value with the text t.

Labels a point in plot coordinates. The position of the label is
by default at the lower right of the point. The label can be simple
text or an RGB matrix, e.g. parsed from a Latex formula.

text : String, vector of strings or RGB matrix.
A vector of strings is line by line. To get an RGB matrix of
color values from a Latex formula, use latex(expr).

x,y : Position in plot coordinates.
offset : In screen coordinates 0..1024.
color : Color of the label.
ypos : One of "u", "c", "l" (upper, center, lower)
xpos : One of "l", "c", "r" (left, center, right)
pos : Combination of ypos and xpos, such as "ur"

Examples:
>plot2d("x^2",r=2); label(["Ursprung","(0,0)"],0,0):

>function f(x) := x^3-x; ...
>plot2d("f",r=2); ...
>label("Min",1/sqrt(3),f(1/sqrt(3)),pos="lc"); ...
>label("Max",-1/sqrt(3),f(-1/sqrt(3)),pos="uc"); ...
>label(latex("y=x^3-x",factor=2),-1,1,pos="ur"):

See:   labelbox (Plot Functions),   latex (Plot Functions)
```
```function labelbox (labels, styles="-", colors:real=1,
x=0.98, y=0.02, style="O#", color=0,
w=none, points=0, tcolor=none, left=0, wt=0.3,
latex=0, scale=1, latexwidth=5)
```
```  Plot a box with labels and line styles for the functions.

A label box is a list of labels for each function in the plot. The
box shows a string and a line in the style and color of the
function for each function. For point plots the box can show point
styles.

labels : string, or vector of strings
styles : string or string of vector, styles of the functions
colors : real vector, colors of the functions
w : width of the box (fraction of plot window)
x, y : upper right corner of label box (fractions)
points : flag or vector of flags.
color : background color
style : background style
left : align at the top left corner (default is top right)
wt : fraction of the width for the text
latex : parse each label through Latex and plot the formulas
scale : take higher lines than the normal text height
latexwidth : We assume that Latex formulas are 5 characters wide

For a transparent box set style="t" and color=black for a black
boundary. Set color=transparant for no boundary.

>labelbox(["x+x^3","x^4"],colors=[black,blue],styles=["-","--"]):

See:   label (Maxima Documentation)
```
```function textbox (s, x=0.98, y=0.02,
style="O#", color=0, tcolor=none, w:real=none,
left=0, spaces=2, scale=1/3, center=false)
```
```  Plot a box with text.

x,y :
An anchor for the upper left corner of the box (fractions of plot
area)

s : A string or a vector of strings, one for each line of text
tcolor : Color or an array of colors for the text lines
w : an optional width of the box (fraction of plot area)
left : align at the left edge (default is right edge)
center : center text in its box

For styles and colors see labelbox().

>function f(x) &= x^3-x; ...
>plot2d(f,r=2); ...
>textbox(latex(&f(x),factor=2,color=green),0.4,0.2):

See:   label (Plot Functions),   label (Maxima Documentation),   labelbox (Plot Functions)
```
```function plotbar1 (x:number,y:number,w:number,h:number)
```
```  Plots a single bar rectangle with x,y,w,h in plot coordinates.

Use barstyle() and barcolor() to modify the bar.

See:   bar (Euler Core)
```
```function plotbar (x,y,w,h,color=none,st=none)
```
```  Plots bars with x,y,w,h in plot coordinates.

The parameters can be vectors.

x,y : lower left coordinate
w,h : width and height
color : color of bars
style : style of bars

See:   bar (Euler Core)
```
```function barclear ([x,y,w,h],color=0,style="O")
```
```  Clear a region in screen coordinates

This can also be used to draw rectangles with specific style and
color. The styles and colors will be reset after the plot.

See:   bar (Euler Core)
```
```function xplotbar (x,y,w,h,st:string="#O")
```
```  Plots a bar with x,y,w,h in plot coordinates.

Uses the plot coordinates from the last plot! Use setplot() to set
new plot coordinates. Draws coordinates below the bar. use
barstyle() and barcolor() to modify the bar.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function xplotrange (r:real vector, v:real vector)
```
```  Plots a bar plot of the multiplicities v[i] in the ranges r[i],r[i+1].

Obsolete. Use plot2d with the histogram=1 option.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function scalematrix (A)
```
```  Scales a matrix A, so that its value are in the range from 0 to 1.
```
```function args select
```
```  Coordinates {x,y} of mouse clicks

Stops if user clicks above the window. The function returns vectors
{x,y} of the clicked coordinates.

See:   mouse (Euler Core)
```

## Plotting Text

```function textheight
```
```  Height of a letter.
```
```function textwidth
```
```  Width of a letter.
```
```function ticks (a=0, b=none, finer=false, vertical=false, n=none)
```
```  Ticks to be used for intervals [a,b].

This function is used to compute the ticks for plots. It tries to
show ticks of major decimal values, but not too many or too few.
The target number of ticks is 5, but for small windows this
number is reduced.

a,b : Plot range
finer : compute for the fine grid in grid=8
vertical : compute grid for vertical plots (respect aspect ratio)
n : target number of ticks

The default for n is in the variable defaultnticks. Start value is
5.

See:   xplot (Plot Functions),   ygrid (Plot Functions),   xgrid (Plot Functions)
```
```function xplot (x=0,y=0,grid=2,ticks=1,frame=1)
```
```  Works like plot, but shows axis ticks.

This function is called by plot2d(). The user should prefer to call
plot2d(). xplot() without parameters shows only axis ticks and the
grid.

See:   plot (Euler Core),   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function xmark (x=0,y=0,grid=2,ticks=1)
```
```  Works like mark, but shows axis ticks.

xmark() shows only axis ticks and the grid.

See:   mark (Euler Core),   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function setplotm
```
```  The user can choose the plotting coordinates with the mouse.

Returns plot coordinates.
```
```function niceform (x,n=10,f=1)
```
```  Return a string, containing a nicely formatted of x
```
```function gridstyle (st1:string=none, st2:string=none,
color=none, textcolor=none, framecolor=none, grid=none)
```
```  Set the grid styles and colors and the frame color.

st1 : axis lines
st2 : other grid lines
color : grid color
textcolor : default text color for plots
framecolor : frame color
grid : Number for grid styles (see plot2d)

See:   linestyle (Euler Core),   rgb (Plot Functions),   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function gridcolor (c:integer=3)
```
```  Set the grid color.
Returns the current color
See plot2d,rgb
```
```function comment fillcolor ([color1, color2])
```
```  Set the fill color for both sides of 3D plots.

fillcolor(none) or fillcolor() simply returns the old colors as a
1x2 vector of colors.
```
```function xgrid (xx, f=1, grid=2, ticks=1, color=none, ..
xt=none, ylevel=none, textcolor=none)
```
```  Draws vertical grid lines on the plot window at x0,x1,...

xgrid([x0,x1,...],f) additionally writes x0/f to the axis.

f : factor (like 10^5)
grid : 2 for normal grid (see plot2d)
ticks : write labels below the axis
color : tick color
xt : use these numbers for the grid
ylevel : draw the grid at this y level

The default values for the grid styles are defaultgrid1,
defaultgrid2,defaultgridcolor.

See:   ygrid (Plot Functions),   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function xtick (x:real vector, s=none, latex=false)
```
```  Set non-conformal ticks to the x-axis

x : real or real vector
s : string, string vector or RGB image (if x is real)
latex : parse string in s through LaTeX

See:   xgrid (Plot Functions),   xaxis (Plot Functions),   xaxis (Maxima Documentation),   latex (Plot Functions)
```
```function ygrid (yy, f=1, grid=2, ticks=1, color=none, ..
yt=none, xlevel=none, textcolor=none, vertical=none)
```
```  Draws horizontal grid lines on the plot window at y0,y1,...

ygrid([x0,x1,...],f) additionally writes x0/f to the axis.
Parameters similar to xgrid().

>plot2d("x^3-x",<grid); plot()
[-2,  2,  -6,  6]
>ygrid(ticks(-6,6,n=4));
>xgrid(-2:2);

See:   xgrid (Plot Functions),   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function yaxis (x, yy=none, yt=none,
color=none, textcolor=none, style=none, gridstyle=none,
grid=false, vertical=false, left=true, axis=true,
zero=false, ticks=1, labels=true)
```
```  Draws a y-axis to the plot window

This function manually draws an axis with labels and grid lines
vertical to the axis.

x : x-coordinate of the axis
yy : y-axis ticks of the axis (none: no ticks)
yt : labels of axis ticks (real or string vector, none: take yy)
color,style : color and style of axis
textcolor : color of labels
gridstyle : style of grid lines (rectangular to axis)
grid : draw grid lines (true or false)
vertical : draw labels vertically
left : draw labels left of axis
axis : draw axis line (true or false)
zero : draw the label for 0
ticks : draw small ticks at the labels

>fullwindow(); setplot(0,1.05,0,1.1); clg;
>xaxis(0,0:0.1:1,style="->");
>yaxis(0,0.1:0.1:1,style="->",>left);
>yaxis(1,style=".",>grid);
>yaxis(1.05,[1,0.5,0.25],>grid,<axis);

See:   xaxis (Plot Functions),   xaxis (Maxima Documentation)
```
```function xaxis (y, xx=none, xt=none,
color=none, textcolor=none, style=none, gridstyle=none,
grid=false, top=false, axis=true,
zero=false, ticks=1, labels=true)
```
```  Draws a y-axis to the plot window

This function is similar to yaxis().

top : labels on top of the axis

See:   yaxis (Plot Functions),   yaxis (Maxima Documentation)
```
```function xrange ()
```
```  Writes the range of x below the x axis
```
```function xlabel (s, x:real=none, color=none, tcolor=0)
```
```  Puts the label text at the x-axis

s : string, string vector or RGB image
x : if present, x position of the label

>plot2d("sin(2pi*x)",0,1); ...
>xlabel(u"&phi;"); ...
>ylabel(u"sin(&phi;)"):

See:   text (Euler Core),   text (Plot Functions),   ylabel (Plot Functions),   ylabel (Maxima Documentation),   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function yrange ()
```
```  Writes the range of y besides the y axis.
```
```function ylabel (s,y=none,edge=none,vertical=none,
color=none,tcolor=0)
```
```  Puts the label text at the y-axis

edge : align with left of screen window
vertical : vertical text (on by default)

See:   xlabel (Plot Functions),   xlabel (Maxima Documentation)
```
```function plotwindow
```
```  Sets the plot window to the screen coordinates.

This function makes the screen coordinates and the plot coordinates
agree.
```
```function getwindowfromplot
```
```  Get the window coordinates from the plot coordinates

This is useful for plotrgb.

>getwindowfromplot()
```

Windows

```function upperwindow (title="")
```
```  Select the upper half of the plot window for a plot

See:   figure (Plot Functions)
```
```function lowerwindow (title="")
```
```  Select the lower half of the plot window for a plot

See:   figure (Plot Functions)
```

```function args adaptiveeval (f\$:call, g\$:call, a, b,
eps=0.01, amin=1e-5, amax=1e5)
```
```  Compute f\$(x), g\$(x) for t in [a,b] with adaptive step size.

eps is the target accuracy.
amin and amax are the minimal and maximal step size.
amax is also the initial step size.
f and g can be expressions in x or user defined functions.
Returns {x,y}

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation),   adaptiveevalone (Plot Functions),   adaptive (Numerical Algorithms)
```
```function args adaptiveevalone (g\$:call, a:number, b:number, ..
eps=0.01, amin=0.00001, amax=0.01, square=1)
```
```  Compute g(x) for t in [a,b] with adaptive step size.

eps is the target accuracy.
amin and amax are the minimal and maximal step size.
amax is also the initial step size.
f and g can be expressions in x or user defined functions.
Returns {x,y}

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```

## Colors

Euler can use any color with the rgb function.

But there are 16 pre-defined functions, which use the integer indices 0-15: white=0,black=1,red=2,green=3,blue=4, cyan=5, olive=6, lightgray=7, gray=8, darkgray=9, orange=10, lightgreen=11, turquoise=12, lightblue=13, lightorange=14, yellow=15.

Moreover, there are special colors: 255 for transparent grid plots, -1, -2 for spectral colors in hue plots.

```function rgb (r,g,b)
```
```  Computes a RGB color from [0,1]-values

Returns an integer encryption of the color.
Use to set rgb colors instead of a color index,
and to define an image to be saved on disk.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation),   putred (Euler Core),   putgreen (Euler Core),   putblue (Euler Core),   savergb (Euler Core)
```
```function args getrgb (x)
```
```  Computes the red, green and blue parts from an rgb color.

Used to decompose image pixels into colors.
Returns {r,g,b}

See:   getred (Euler Core),   getblue (Euler Core),   getgreen (Euler Core),   loadrgb (Euler Core)
```
```function computehue (x,y,z,L=[0,0,1],amb=0.1,max=0.9,hue=1)
```
```  Computes the shading for a surface

This is used in various plot functions.

x,y,z : coordinates of the surface
l : direction of light
amb : ambient light
max : maximal hue value
hue : -2, -3, -4 for x, y, z direction (default 1)

```

## Save Images to Files

This can should be done in the menu. But there are also functions for Euler scripts.

```function overwrite savepng (filename:string, w:integer=0, h:integer=0, ..
antialias:integer=1)
```
```  Save the current graphics as PNG file in current directory.

Saves the current graphics in PNG format. If antialias=1, then
the function takes more time, and needs more memory, but the output
looks smoother. If w=0, "savepng" uses the screen width. If h=0,
the current aspect ratio with the current width is used.

The current directory is set by the "cd" command, or, if a
notebook is saved or opened.

See:   savesvg (Plot Functions),   saveps (Plot Functions)
```
```function overwrite savesvg (filename:string, w:integer=0, h:integer=0)
```
```  Save the current graphics as SVG file in current directory.

Saves the current graphics in the format SVG (scalable vector
format). If h=0, the current aspect ratio with the current width is
used.

The current directory is set by the "cd" command, or, if a
notebook is saved or opened.

See:   savepng (Plot Functions),   saveps (Plot Functions)
```
```function overwrite saveps (filename:string)
```
```  Save the current graphics as EPS file in current directory.

Saves the current graphics in EPS (encapsulated postscript) format.

The current directory is set by the "cd" command, or, if a
notebook is saved or opened.

See:   savepng (Plot Functions),   savesvg (Plot Functions)
```
```function fcontour (f\$,xmin=none,xmax=1,ymin=-1,ymax=1,r=none,
n=40,nc=defaultnc,hue=0,level="auto",
contourcolor=none, contourwidth=1,style="#",outline=1,frame=1)
```
```  Draw contour lines of a function or expression in x and y.

Obsolete. Use plot2d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function datacontour (Z:real,
a:number=0, b:number=1, c:number=0, d:number=1,
nc=defaultnc, hue=0, level="auto",
contourcolor=none, contourwidth=none, style="#", outline=1,
frame=1)
```
```  Draw contour lines of a data matrix.

Obsolete. Use plot3d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function flevel (f\$,level=0,xmin=-1,xmax=1,ymin=-1,ymax=1,n=50,maps=0)
```
```  Draw contour lines of a function or expression in x and y

Obsolete, since plot3d should be used now.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function frotate (f\$,a,b,n=40,nt=40,scale=1,frame=1, ..
xlabel="x",ylabel="y",zlabel="z")
```
```  Show a rotated plot of a function

Obsolete, since plot3d with user=1 should be used now.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function triangle
```
```  Obsolete function
```
```function f3dimplicit (f\$:string, x:real vector, y:real vector, z:real vector, ..
fr:integer=1, xlabel:string="x", ylabel:string="y", zlabel:string="z", ..
scale:real=1, direction:integer=4, maps=0, ..
contourcolor=1, contourwidth=1)
```
```  Implicit 3D plot contours at z-values.
```
```function solidhue (x:real, y:real, z:real, h:real,
f:number=1, level=none, nc:index=10, values=none,
contourcolor=1, contourwidth=1,
dl=none, breaks=none, limits=none,
linewidth=none)
```
```  Shaded solid 3D-plot of x,y,z

h is the shading and should run between 0 and 1.
f determines, if h is scaled to fit in between 0 and f.

See:   solid (Euler Core),   solidhuecontour (Euler Core),   solidhuecontour (Plot Functions),   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function solidhuecontour (x:real, y:real, z:real, h:real,
v:real, w:real, breaks=none, limits=none)
```
```  Shaded solid 3D-plot with contour lines.

This function is just for compatibility with older Euler files. It
calls the built-in solid function.

See:   solid (Euler Core),   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function drawbutton (text:string, x:real scalar, y:real scalar, w:real scalar)
```
```  Draw a button with the text at x,y with w character width. x
centered and y top of the label. Return the button rectangle. This
function can be used to program user interaction with clicks onto
the screen.

See:   inbutton (Plot Functions)
```
```function inbutton (b:real vector, s:real vector)
```
```  Test if the screen coordinates s are with in the button rectangle b.
Get s with toscreen(mouse()) to ask the user for a click.

See:   drawbutton (Plot Functions),   mouse (Euler Core)
```
```function fplot (f\$,a=0,b=0,n=200,grid=2)
```
```  Plots the function f in [a,b]

fplot("f") or fplot("f",,,n,...) plots f in the old interval.
fplot uses map for the evaluation of the function "f".
f\$ may be an expression in x.

Deprecated!

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function f3dplotlight (f\$,
xmin=-1,xmax=1,ymin=-1,ymax=1,n=40,
scale=1,fscale=1,light=[0,0,1],amb=0.1,max=0.9,fr=1,
xlabel="x",ylabel="y",zlabel="z",level=none,hue=1,
maps=0,contourcolor=1,contourwidth=1,
dl=none,limits=none, nc=defaultnc,
cp=0, cpcolor=1, cplevel="auto", cpdelta=0.05, zlim=none)
```
```  Plots a function f(x,y,...) in a square.

Also f3dplot("f",xmin,xmax,ymin,ymax,n;...).
f3dplot uses map for the evaluation of the function "f".
"f" may be an expression in x and y.

Obsolete. Use plot3d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function f3dplotpolar (f\$,rmax=1,n=40,scale=1,fscale=1, ..
frame=1,wire=0,xlabel="x",ylabel="y",zlabel="z",maps=0,
cp=0, cpcolor=1, cplevel="auto", cpdelta=0.05)
```
```  Draw a function defined on the circle with radius rmax.

f3d uses map for the evaluation of the function "f".
n is the spacing.

Obsolete. Use plot3d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function f3dplotpolarl (f\$,rmax=1,n=20,scale=1,fscale=1,
light=[0,0,1],amb=0.2,max=0.8,frame=1,
xlabel="x",ylabel="y",zlabel="z",
level="auto",hue=1,maps=0, dl=none, limits=none,
cp=0, cpcolor=1, cplevel="auto", cpdelta=0.05, nc=defaultnc)
```
```  Draw a function defined on the circle with radius rmax.

f3d uses map for the evaluation of the function "f".
n is the spacing.

Obsolete. Use plot3d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function mark3 (x,y,z)
```
```  Plots points in three dimensions.

x,y,z must be 1xn vectors.

Obsolete. Use plot3d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function clipping (flag:integer=true)
```
```  Sets clipping off or on globally for 2D plot functions.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function overwrite plot (x=0, y=0)
```
```  Plots the values (x(i),y(i)) with the current style.
If x is a matrix, y must be a matrix of the same size.
The plot is then drawn for all rows of x and y.
The plot is scaled automatically, unless hold is on.
plot(x,y) and plot() return [x1,x2,y1,y2], where [x1,x2] is the range
of the x-values and [y1,y2] of the y-values.
plot(x) is the same as plot(1:cols(x),x).

To turn off the clipping set defaultclipping=false

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function overwrite mark (x=0,y=0,c=1)
```
```  Plots markers at (x(i),y(i)) according the the actual marker style.
Works like plot.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function cplot (z)
```
```  Plots a grid of complex numbers.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function scale (z:real, scale:number=1,	center:number=0,
retscale:integer=0)
```
```  Scale the matrix z into [0,scale]

z : real matrix
scale : maximal absolute value of the returned matrix
retscale : returns the scaling factor f and center c too.

center : Scales into [-scale,scale]

If >retscale, the function returns {znew,f,c}.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function scalez (z,scale)
```
```  Scale the matrix z to [-scale,scale].

This is a function used by plot3d with parameter scale=1.
Returns the scaled matrix and and the scaling factor.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function scalez0 (z:real, scale:number, center:integer=1)
```
```  Scale the matrix z to [-scale,scale] symmetrical to 0.

This is a function used by plot3d.
Returns the scaled matrix and the scale.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function f3d (f,m=40)
```

```function f3dplot (f\$,xmin=-1,xmax=1,ymin=-1,ymax=1,n=40, ..
scale=1,fscale=1,frame=1,wire=0,xlabel="x",ylabel="y",zlabel="z", ..
sliced=0,maps=0,wirecolor=1,
cp=0, cpcolor=1, cplevel="auto", cpdelta=0.05, nc=defaultnc)
```
```  f3dplot("f") plots a function f(x,y,...) in a square.

f3dplot uses map for the evaluation of the function "f".
"f" may be an expression in x and y.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function overwrite density (x,f=0.9,amb=0.1)
```
```  Makes density plot of the values in the matrix x
scaled to fit into [0,f].

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function plot3dbars (x : real vector, y : real vector, z : real, ..
z0 : real scalar)
```
```  Plot bars at x[i],y[j] with height z[i,j].

The bars have limits x[i],x[i+1] and y[j],y[j+1] and use
the values z[i,j]. z must be at least (n-1)x(m-1), if
x is 1xn and y is 1xm. The bars are sorted correctly before
they are plotted by plotcubes.

A comfortable way to use is is via plot3d and bar=true.

See:   plotcubes (Plot Functions),   plot3d (Maxima Documentation)
```
```function overwrite plotcubes (M, color=none,
xy=false, midpoints=false)
```
```  Plot cubes (parallel to the axes)

The rows of M contain [x1,x2,y1,y2,z2,z2] with lower and upper
limits for the sides of the cubes. The cubes are sorted either by
distance of the midpoint to the eye, or by distance of the
projection to the x-y-plane.

See:   plot3dbars (Plot Functions)
```
```function overwrite insimg (lines:index=35, name:string="", ..
antialias=1, crop=none)
```
```  Insert the graphics into the notebook.

Insert the graphics with default size and name into the notebook.
The image appears in the notebook with the given height in lines.
If the name is not empty, the image will be saved under this name
when the notebook is saved. If the image is too small it will take
less lines.

antialiased : looks good for most plots, but not for all.

crop : inserts only a top portion of the graphics. The crop can be
a vector [top,bottom,left,right] of numbers from 0 to 1, or it can
be [top,bottom], or only bottom. The defaults are [0,1,0,1].

The crop works well with the aspect function. In fact, if an aspect
is active with larger width than height, only the active portion of
the image is inserted automatically.

This function is used by the : at the end of command lines.

>plot2d("x^3"); insimg();
>plot2d("x^3"): // simpler alternative

See:   insimg (Euler Core),   loadimg (Euler Core),   loadimg (Plot Functions),   aspect (Euler Core),   aspect (Plot Functions)
```
```function overwrite insrgb (x:real, lines:integer=25, name:string="")
```
```  Insert an rgb image matrix into the notebook.

The image appears in the notebook with the given height
in lines. If the name is not empty, the image will
be saved under this name when the notebook is saved.
If the image is too small it will take less lines.

>M=ones(1000,1000)*linspace(0,1,999);
>insrgb(rgb(M,0.5,M),10);

See:   insimg (Euler Core),   insimg (Plot Functions)
```
```function plotrgb (x:real, window:real vector=none, tcolor=none)
```
```  Plot an rgb image into the plot window.

The window can be a vector with screen coordinates or none. For
sync with the plot coordinates use getwindowfromplot();

>s=linspace(0,1,100); t=s'; c=rgb(s,t,0);
>plot2d(none,0,1,0,1); plotrgb(c);

See:   getwindowfromplot (Plot Functions)
```
```function overwrite loadimg (filename:string, lines:index=35,
scale:positive=1)
```
```  Insert an image from file.

The image appears in the notebook with the given height
in lines.

filename : filename including extension (jpg or png)
n : maximal number of lines to be used
scale : scale with this factor

See:   insimg (Euler Core),   insimg (Plot Functions),   loadimg (Euler Core)
```
```function overwrite loadanaglyph
```
```  loadanaglyph("left","right") or loadanaglyph(n,"left","right")

Loads two images, combines them to one anaglyph, and inserts the
images into the notebook.

n : maximal number of lines to be used (default is 40)

```
```function figure (n:natural, m:index=none, smaller=0)
```
```  figure (nc,nr) or figure(nc), figure(0) for sub-windows

figure(nr,nc) divides the graph window into nr rows x nc columns of subplots
figure(n) sets the current drawing window to the nth subplot counting
by rows.

figure(0) sets the plot back to the normal window

smaller : if set, there is more space for vertical labels.

>figure(3,1,>smaller); ...
>figure(1); plot2d("sin(x)",0,2pi,yl="sin"); ...
>figure(2); plot2d("cos(x)",0,2pi,yl="cos"); ...
>figure(3); plot2d("sinc(x)",0,2pi,yl="sinc"); ...
>figure(0):

```
```function title (s, color=none, x:real=none)
```
```  Plots a title to the graphics window.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation),   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function settitle (s, color=none, x:real=none)
```
```  Plots a title to the graphics window.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation),   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function fwebplot (f\$:string, a:real scalar, b: real scalar, ..
xstart: real scalar, n: index, color=black)
```
```  Plots an iteration of fff on [a,b] starting from xstart, n steps
This function can be used to study, demonstrate or understand
fixed point iteration of the type x(n+1) = f(x(n)).

See:   iterate (Numerical Algorithms),   sequence (Numerical Algorithms)
```
```function args vectorfield (f\$:string,
x1: real scalar=-2, x2: real scalar=2, ..
y1:real scalar=-2, y2: real scalar=2,
r=none,	cx=0, cy=0,
nx:index=20, ny:index=20,
thickness=1, color=black, frame=1,
plot=true)
```
```  Draw the vector field of a differential equation in x and y.

expr : expression "f(x,y)", which computes the
derivative of y(x) at x.
x1,x2,y1,y2 : bounds of the plot
r,cx,xy : alternative way to enter the bounds
nx, ny : number of arrows in each direction
thickness,color,frame : see plot2d
plot : do not plot but return x,y for later plots with plot2d().

>vectorfield("x*y",r=1,cx=1,cy=1):

See:   vectorfield2 (Plot Functions),   ode (Numerical Algorithms)
```
```function args vectorfield2 (f1\$:string, f2\$:string, ..
x1: real scalar=-2,x2: real scalar=2,
y1: real scalar=-2,y2: real scalar=2,
nx:index=20, ny:index=20,
r=none,	cx=0, cy=0,
nx:index=20, ny:index=20,
scale=1, normalize=0,
thickness=1, color=black, frame=1,
plot=true)
```
```  Draw the vector field of a differential equation in x and y.

expr1 and expr2 : expressions "f(x,y)", which compute the
x- and y-value of the derivative of y(x) at x.
scale : scaling factor for the arrows
x1,x2,y1,y2 : bounds of the plot
r,cx,xy : alternative way to enter the bounds
nx, ny : number of arrows in each direction
thickness,color,frame : see plot2d
normalize : derivative vectors are normalized
plot : do not plot but return x,y for later plots with plot2d().

>>vectorfield2("-y","x",r=1):
>vectorfield2("x","x*y",>normalize):

See:   ode (Numerical Algorithms)
```
```function overwrite view
```
```  view(distance, tele, angle1, angle2) sets the perspective for solid and view.
distance is the eye distance, tele a zooming factor.
angle1 is the angle from the negativ y-axis to the positive x-axis.
angle2 is the angle to the positive z-axis (the height of the eye).
view() returns the current value of view in a vector.
view is used in plot3d as the default view.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation),   zoom (Plot Functions)
```
```function zoom (f:positive=none)
```
```  Set the zoom distance to d.

See:   view (Euler Core),   view (Plot Functions),   view (Maxima Documentation)
```
```function viewangle (a:real scalar=none)
```
```  Set the view angle to a.

See:   view (Euler Core),   view (Maxima Documentation)
```
```function viewheight (a:real scalar=none)
```
```  Set the view height angle to a.

See:   view (Euler Core),   view (Maxima Documentation)
```
```function viewdistance (d:positive=none)
```
```  Set the view distance to d.

See:   view (Euler Core),   view (Maxima Documentation)
```
```function f3daxis (f\$:string, n:index=25)
```
```  Draw a function defined on [-1,1]^2 with x-, y- and z-axis.
f3daxis uses map for the evaluation of the function "f".
2n is the spacing.
Fixed view, cannot be rotated.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function f3daxispolar (f\$:string, n:index=20)
```
```  Draw a function defined on [-1,1]^2 with x-, y- and z-axis.
2n is the spacing.
f3daxispolar uses map for the evaluation of the function "f".
Fixed view, cannot be rotated.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function stereo (f\$:string, a:number=-0.05, s:index=500, ..
d:number=1, parallel:natural=0)
```
```  Stereo plot of the function f from two viewpoints
Calls the function f, which must be the name of
a 3D plot command, and does it twice in two different
windows. Many people are able to view a 3D picture.

There are two ways: parallel view and squint view.
Most people find the latter easier. It is the default
for this function.
```
```function parameterplot (f:string, a:number, d:number, ..
display=1, c=800, r=100, ..
amax=1e30, amin=-1e30)
```
```  Call the plot function f with parameter a adjustable by user.

Animate a paramter with the up/down keys, and show a plot depending
on that parameter. The space key resets the default parameter, and
the return key ends the function.

f : function of a (and additional semicolon parameters)
a : starting value parameter a
d : increment with one keystroke
display : flag for the display of the parameter value
c,r : coordinates for the display
amax,amin : limits for the display

See:   twoparameterplot (Plot Functions)
```
```function twoparameterplot (f\$:string, a:number, b:number, d:number, ..
display=1, c=800, r=100, ..
amax=1e30, amin=-1e30)
```
```  Call the plot function f with parameter a adjustable by user.

Animate a parameter a with the up/down keys, and a parameter b with
left/right keys, and show a plot depending on that parameter. The
space key resets the default parameter, and the return key ends the
function.

f : function of a,b (and additional semicolon parameters)
a : starting value of parameter a
b : second parameter b
d : increment with one keystroke
display : flag for the display of the parameter values
c,r : coordinates for the display
amax,amin : limits for the display

```
```function args makeimpulse (x:real vector,y:real vector,d=0.1)
```
```  Compute {x1,y1} for impulse bar plots.

Computes the correct input for an impulse bar plot
at points x with values y.

x : sorted x parameters
y : values
d : radius of the plot intervals
```

## Functions for Animated Graphics

```function dragpoints (f\$ : string, x : real, y : real,
status="Drag one of the points!")
```
```  Lets the user drag points on a user defined plot.

This function calls a function f(x,y), which draws some plot
depending on the points at coordinates x[i] and y[i]. Then it lets
the user drag one of the points with the mouse.

f : f(x,y[,select]) a plot function. select is the index of the
selected point, if not select==0.

Additional arguments are passed to f.

Returns {x,y}

Example:
>function f(x,y) := plot2d(x,y,>points,a=0,b=1,c=0,d=1);
>{x,y}=dragpoints("f",random(1,10),random(1,10));
```
```function dragvalues (f\$, names, values, ranges, stops=100,
x=0.98, y=0.02, w=0.4, tcolor=none, digits=none,
```
```  Let the user drag parameters for a plot.

This function lets the user drag values for plots. A box with
values appears, by default in the upper right, with an optional
heading. The values can be dragged to the right or left, and change
within given ranges and steps.

f : A plot function depending on a vector of parameters.
names : The names of the parameters for the display.
values : Initial values of the parameters (string vector of length
n or string)
ranges : A nx2 vector of ranges for the values
stops : A vector with the number of subintervals for each range
x,y,w : Position anchored in the top right (fraction of plot window)
tcolor : A vector with colors for the values or one scalar color
digits : A vector of digits for rounding the values or a scalar
hcolor : The color of the heading
status : An optional string for the status line

Example:
>function f([a,b]) := plot2d("a*x^2+b*x";a,b,r=1);
>dragvalues("f",["a","b"],[0,0],[-1,1;-1,1],digits=2, ...
```

The following functions in this section are obsolete, since plot3d can now animate 3D graphics under user control. E.g. plot2d and plot3d have the parameter >user.

```function animate (d:real scalar=0.1)
```
```  Animate pre-defined pages with delay d.

This animates predefined images. The function was designed for
slower computers or for complicated plots. If the computer is fast
enough, plots can also be generated directly. Then wait() will
issue the display of the current plot.

For animate(), the pages must be generated with calls to addpage(),
as in the following example.

deletepages();
title("Creating Animation");
showpage(1);
loop ...
... // graph something
end;

See:   addpage (Euler Core),   showpage (Euler Core),   wait (Euler Core),   rotate (Plot Functions)
```
```function rotate (f\$:string, d:real scalar=0.01, n:integer=120)
```
```  Shows a rotating animation of the plot f\$,

The plotting function f\$ must produce a 3D plot. This functions
used addpage() to pre-compute all plots. Seen the remarks in
animate() for an easier method.

Obsolete, since the plot can now be rotated with plot3d under user
control.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation),   animate (Plot Functions)
```
```function view3d (f\$:string, d:real scalar=0.1)
```
```  Calls the plot f\$ and waits for key strokes to rotate it.

Use the cursor keys for rotation, del and backspace, or space, to

Obsolete, use plot3d().

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function fanimate (f\$:string, t:vector, d:real scalar=0.01)
```
```  Animate the function f\$

f\$ should display some graphics depending on t. Additional
parameters are passed to f. This function used addpage() to
pre-compute the plots. See the remarks in animate() for an easier
method.

```

Most of the following functions need never be used, since 3D graphics should be done with plot3d.

```function getframe (x,y,z)
```
```  Gets a box around all points in (x,y,z).

Returns [xmin,xmax,ymin,ymax,zmin,zmax]
```
```function cubescale (x,y,z)
```
```  return a scaling that makes (x,y,z) fit to the unit cube.
```
```function framedplot (f\$:string, frame:real vector,
sframe:real vector=none,
xl:string="x", yl:string="y", zl:string="z",
ticks:integer=1,
view=none, zoom=none, distance=none, angle=none, height=none,
center=none,fr=1)
```
```  General function for framed plots.

This function does the same as the functions called by plot3d. It
draws a frame around a plot. The frame is drawn in two parts, one
in the back and one in the front. It can display ticks, which may
have nothing to do with the frame itself (sframe parameter).

A function using this function can be used in plot3d with parameter
>own to allow anaglyphs or turning.

f : A 3D plot function. This can also be plot3d with parameter
<frame. Semicolon parameters are passed to f.

frame : The frame. take care that the plot fits into the frame. The
frame is a vector of the form [xmin,xmax,ymin,ymax,zmin,zmax]

sframe : The tick values for the frame. If sframe=none then frame
is used.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function framedsolid (x:real, y:real, z:real,
scale:real vector=1, fr:integer=1, hf:number=1,
disconnect=none,
xlabel:string="x", ylabel:string="y", zlabel:string="z",
sliced:integer=0, bar:integer=0, z0:real=0,
frame:real vector=none, sframe:real vector=none,
cp=0, cpcolor=1, cplevel="auto", cpdelta=0.05, nc=defaultnc,
linewidth=none)
```
```  3D plot with frame.

x, y, and z must be compatible matrices. The determine the
coordinates of the 3D images of a parameter matrix.

If scale is specified, then the plot is scaled to fit into a cube
of side length 2*scale centered at 0.

If fr=0 then no frame will be drawn around the plot.

disconnect is a vector of indices containing the rows of the
matrix, which should not be connected.

sliced is a parameter, which produces sliced plots into the x, or
the y direction. Should only be used for regular x,y grids.

bar is a parameter, which makes the plot into steps. Should only be
used for regular x,y grids.

This function should only be used via plot3d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function autolevel (a,b,nc,d=0.1)
```
```  Compute automatic levels between a and b
```
```function plotcontourplane (x, y, z, style=1, color=1,
level=none, delta=0.05, nc=defaultnc, grid=false,
contourcolor=none, scale=false, linewidth=none)
```
```  Plot a contour plane below the 3D plot

This is called by plot2d() if >cp is set. The functions projects
the contours of the plane with coordinates x,y,z to a plane below
the plot.

x,y,z : coordinates of the surface
style : 1=level lines only, 2=shading and level lines
level : "auto", "thick", "thin" or level values
If level is a 2xn matrix it plots ranges
cpcolor : color of the shading
cpdelta : distance from below the plot
nc : number of lines for automatic levels
grid : grid values for an additional grid.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```
```function vieweye ()
```
```  The position of the eye depending on center and view
```
```function framedsolidhue (x:real, y:real, z:real, hue, ..
scale:real vector=1, f:number=1, fr:integer=1, hf:number=1, ..
xlabel:string="x", ylabel:string="y", zlabel:string="z", ..
level=none, values=none,
light=[0.5,0.5,1], amb=0.1, max=0.9, huecolor=0, ..
contourcolor=1, contourwidth=1, z0=0,
frame=none, sframe=none,
dl=none, limits=none,
nc=defaultnc, cp=0, cpcolor=1, cplevel="auto", cpdelta=0.05,
linewidth=none, zlim=none)
```
```  3D plot with hue, and optional level lines.

x, y, and z must be compatible matrices. They determine the
coordinates of the 3D images of a parameter matrix. hue is an
the matrix at each point. E.g., plot3d computes the hue using a
light source.

level is a row vector of level levels, which are to be drawn.
values is a matrix of the same size as x, y, and z which contains
the values, which determine the level. By default, the value will
be z (values=none).

If scale is specified, then the plot is scaled to fit into a cube
of side length 2*scale centered at 0.

If fr=0 then no frame will be drawn around the plot.

disconnect is a vector of indices containing the rows of the
matrix, which should not be connected.

This function should only be used via plot3d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation)
```
```function framedwire (x:real, y:real, z:real,
scale:real vector=1, fr:integer=1, hf:number=1,
xlabel:string="x", ylabel:string="y", zlabel:string="z",
wirecolor:number=none, rowsonly:integer=0, z0:real=0,
frame:real vector=none, sframe:real vector=none,
cp=0, cpcolor=1, cplevel="auto", cpdelta=0.05,
linewidth=none)
```
```  3D wire plot with frame.

x, y, and z must be compatible matrices. They determine the
coordinates of the 3D images of a parameter matrix.

If scale is specified, then the plot is scaled to fit into a cube
of side length 2*scale centered at 0.

If fr=0 then no frame will be drawn around the plot.

With rowsonly=1 the wire will be drawn only in one direction.

The wirecolor can be specified with the variable wirecolor. Use any
of the 16 predefined colors, or an rgb value.

This function should only be used via plot3d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation),   rgb (Plot Functions)
```
```function framedmark3 (x:real, y:real, z:real,
scale:real vector=1, fr:integer=1, hf:number=1,
xlabel:string="x", ylabel:string="y", zlabel:string="z",
color=1, z0:number=0,
frame:real vector=none, sframe:real vector=none)
```
```  3D point plot with frame.

x, y, and z must be row vectors. They determine the coordinates of
the 3D images of the points.

This function should only be used via plot3d.

See:   plot3d (Plot Functions),   plot3d (Maxima Documentation),   rgb (Plot Functions)
```
```function overwrite subgrid (v)
```
```  Sets the sub-grid for grid plots

This is usually called by plot2d() automatically. The sub-grid
determines the number of grid lines which are drawn in a 3D plot.
This allows a finer plot than the visible grid lines indicate. In
plot2d(), the parameter grid= controls the sub-grids.

Calls the built-in function _subgrid, which works with 1x2 vectors.

>plot3d("x^2-y^3",grid=[10,5]):

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation)
```

## MatPlotLib

MatPlotLib is a very nice plotting library for Python. It has to be installed separately into Python. Consult the remarks about the installation of EMT for more details.

```function pyins (lines=35, close=true)
```
```  Insert a Python plot into the notebook

This saves a plot done with MatPlotLib in the working directory of
EMT, and loads the saved file to the current notebook. By default,
the plot is closed. Unclosed plots can be displayed with show() in
a separate window or saved in other formats too.

lines : number of lines for the plot in the notebook
close : close the plot

```

## Logarithmic Plots

These function should not be called directly. Use plot2d to produce log plots.

```function logticks (aa, bb=none, base=10)
```
```  Logarithmic ticks

See:   xlogplot (Plot Functions)
```
```function xlogplot (x:positive, y, xbase=10, color=1,
points=false, frame=1, grid=2, ticks=1)
```
```  Logarithmic plot

Instead of this, plot2d() should be used with the parameter
logplot=1.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation),   ylogplot (Plot Functions),   xylogplot (Plot Functions)
```
```function ylogplot (x, y:positive, ybase=10, color=1, points=false,
frame=1, grid=2, ticks=1)
```
```  Logarithmic plot

Instead of this, plot2d() should be used with the parameter
logplot=2.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation),   xlogplot (Plot Functions),   xylogplot (Plot Functions)
```
```function xylogplot (x:positive, y:positive,
xbase=10, ybase=10, color=1, points=0,
frame=1, grid=2, ticks=1)
```
```  Logarithmic plot

Instead of this, plot2d() should be used with the parameter
logplot=3.

See:   plot2d (Plot Functions),   plot2d (Maxima Documentation),   xlogplot (Plot Functions)
```

## LaTeX

LaTeX needs to be installed separately. I recommend MiKTeX for Windows. If you do not install the full package, you may have to wait a bit, when MiKTeX installs necessary packages. EMT may issue a warning.

```function comment tex (expr:string)
```
```  LaTeX code of the expression.

This calls Maxima to for the LaTeX code of the expression. The
result is a string.

```
```function overwrite texpng (latex:string,
usealias=true, factor=1.0, backcolor=-1, color=none)
```
```  PNG file containing the scanned LaTeX code.

LaTeX must be installed for this. The string will be inserted as a
display formula into a LaTeX document in the working directory of
EMT. Then LaTeX will be called to translate the document. Finally
the DVI file will be transformed into a PNG with "dvipng".

The text color is the current text color as set with textcolor(),
unless set as parameter color. The background color is the color
number 0 of the graphics, usually white. The font size is the
current font size. The scan is always tree times larger than
necessary to allow for anti-aliasing.

usealias : dvipng should alias the formula
factor : make the formula larger by this factor
transparent : use -1 for the current background color of the
graphics, and 0 for the background color of the text.
1 yields a transparent graphics. Note that loadrgb()
ignores transparency.
color : use another color for the text

The output is C:\Users\Username\Euler\eulertemp.png. It is usually
function label() does this.

This is calling the built-in function texpng() with the same
arguments.

See:   loadrgb (Euler Core),   label (Plot Functions),   label (Maxima Documentation),   xlabel (Plot Functions),   xlabel (Maxima Documentation),   ylabel (Plot Functions),   ylabel (Maxima Documentation),   setfont (Euler Core),   setfont (Basic Utilities),   latex: (Euler Core)
```
```function latex (s:string, color=none, factor=1.0)
```
```  RGB matrix containing the scanned LaTeX code.

s : LaTeX code
color : the text color; if none, the default text color is used.
factor: scale the Latex output by this factor.

This combines texpng() and loadrgb() to scan a LaTeX formula to an
RGB matrix. With plotrgb() such a matrix can be plotted into a plot
window. For more details, see texpng().

A symbolic expression can be transformed to Latex by Maxima with
tex(expr).

Returns an image as a matrix of RGB values.

>expr &= integrate(x^2*sin(x),x)
>plot2d(expr,0,2pi,grid=6); label(latex(tex(expr)),1,-10):

See:   text (Euler Core),   text (Plot Functions),   texpng (Plot Functions),   plotrgb (Plot Functions),   label (Plot Functions),   label (Maxima Documentation),   xlabel (Plot Functions),   xlabel (Maxima Documentation),   ylabel (Plot Functions),   ylabel (Maxima Documentation),   tex (Maxima Documentation)
```
```function overwrite text (s, c:real, r:real=none, color=none,
align:integer=-1, vertical=0,
left=none, center=none, right=none, up=none, down=none,
scale=1/3, tcolor=0)
```
```  Put text or RGB matrix on the screen.

This function works for a single string, a vector of strings, or an
RGB matrix of an image, e.g. a LaTeX formula. It can align the text
left, center, or right, or vertically up or down.

RGB images can be from the latex() function. This functions returns
three times enlarged images. Thus the default scale factor is 1/3.

s : string, string vector, or RGB image
c : column in screen coordinates or vector [c,r]
r : row in screen coordinates
color : text color
align : -1,0,1 for left, center, right
vertical : 0,1,2 for not vertical, up, down
left, center, right : sets align
up, down : sets vertical
scale : scale for the RGB image
tcolor : transparency color for the RGB image

>plot2d(''integrate("x^x",1,x)'',0,2,grid=6); ...
>text(latex("f(x) = 'integrate(t^t,t,1,x)"),toscreen(0.5,1)); ...
>g &= integrate(taylor(t^t,t,1,2),t,1,x); ...
>text(latex("g(x) = T_2f(x)",color=red),toscreen(0.5,0.7)):

See:   latex (Plot Functions),   plotrgb (Plot Functions),   label (Plot Functions),   label (Maxima Documentation),   text (Euler Core)
```

Documentation Homepage