KmPlot User Guide and Features
KmPlot User Guide and Features
Klaus-Dieter Möller
Philip Rodrigues
David Saxton
The KmPlot Handbook
2
Contents
1 Introduction 6
3 Using KmPlot 9
3.1 Function Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.1 Cartesian Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.2 Parametric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.3 Functions in Polar Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.4 Implicit Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.5 Differential Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Combining Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Changing the appearance of functions . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Popup menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4 Configuring KmPlot 14
4.1 General Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2 Diagram Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.3 Colors Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.4 Fonts Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5 KmPlot Reference 18
5.1 Function Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.2 Predefined Function Names and Constants . . . . . . . . . . . . . . . . . . . . . . . 18
5.2.1 Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.2.2 Hyperbolic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.2.3 Other Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.2.4 Predefined Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.3 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.4 Mathematical Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.5 Plotting Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
The KmPlot Handbook
6 Command Reference 24
6.1 Menu Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.1.1 The File Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.1.2 The Edit Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.1.3 The View Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.1.4 The Tools Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.1.5 The Help Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
7 Scripting KmPlot 26
4
Abstract
Chapter 1
Introduction
KmPlot is a mathematical function plotter by KDE. It has a powerful built-in parser. You can plot
different functions simultaneously and combine them to build new functions.
• Filling and calculating the area between the plot and the first axis.
6
The KmPlot Handbook
These features help in learning the relationship between mathematical functions and their graph-
ical representation in a coordinate system.
7
The KmPlot Handbook
Chapter 2
and press Enter. This will draw the plot of y = x2 in the coordinate system. Clicking on the Create
button again, select Cartesian Plot, and this time enter the text
y = 5 sin (x)
and hit enter. To select another color for the plot, click the Color button in the section Appearance
at the bottom of the Functions sidebar and select a new color.
N OTE
All changes can be undone via Edit → Undo.
8
The KmPlot Handbook
Chapter 3
Using KmPlot
KmPlot deals with several different types of functions, which can be written in function form or
as an equation:
• Cartesian plots can either be written as e.g. ‘y = xˆ2’, where x has to be used as the variable; or
as e.g. ‘f(a) = aˆ2’, where the name of the variable is arbitrary.
• Parametric plots are similar to Cartesian plots. The x and y coordinates can be entered as
equations in t, e.g. ‘x = sin(t)’, ‘y = cos(t)’, or as functions, e.g. ‘f_x(s) = sin(s)’, ‘f_y(s) = cos(s)’.
• Polar plots are also similar to Cartesian plots. They can be either be entered as an equation in
T, e.g. ‘r = T’, or as a function, e.g. ‘f(x) = x’.
• For implicit plots, the name of the function is entered separately from the expression relating
the x and y coordinates. If the x and y variables are specified via the function name (by entering
e.g.‘f(a,b)’ as the function name), then these variables will be used. Otherwise, the letters x and
y will be used for the variables.
• Explicit differential plots are differential equations whereby the highest derivative is given in
terms of the lower derivatives. Differentiation is denoted by a prime (’). In function form, the
equation will look like ‘f”(x) = f’ − f’. In equation form, it will look like ‘y” = y’ − y’. Note that
in both cases, the ‘(x)’ part is not added to the lower order differential terms (so you would
enter ‘f’(x) = −f’ and not ‘f’(x) = −f(x)’).
All the equation entry boxes come with a button on the right. Clicking this invokes the advanced
Equation Editor dialog, which provides:
• A variety of mathematical symbols that can be used in equations, but aren’t found on normal
keyboards.
• The list of user constants and a button for editing them.
• The list of predefined functions. Note that if you have text already selected, it will be used
as the function argument when a function is inserted. For example, if ‘1 + x’ is selected in
the equation ‘y = 1 + x’, and the sine function is chosen, then the equation will become ‘ y =
sin(1+x)’.
9
The KmPlot Handbook
where:
• f is the name of the function, and can be any string of letters and numbers.
• x is the horizontal coordinate, to be used in the expression following the equals sign. It is a
dummy variable, so you can use any variable name you like to achieve the same effect.
• expression is the expression to be plotted, given in the appropriate syntax for KmPlot. See
Section 5.4.
Min:, Max:
These options control the range of the parameter t for which the function is plotted.
10
The KmPlot Handbook
Note that you can use any name for the theta variable, so ‘r(t) = t’ or ‘f(x) = x’ will produce exactly
the same output.
An implicit expression relates the x and y coordinates as an equality. To create a circle, for exam-
ple, click the Create button and select Implicit Plot from the list. Then, enter into the equation
box (below the function name box) the following:
x ^2 + y ^2 = 25
Step:
The step value in the precision box is used in numerically solving the differential equation
(using the Runge Kutta method). Its value is the maximum step size used; a smaller step
size may be used if part of the differential plot is zoomed in close enough.
11
The KmPlot Handbook
When right-clicking on a plot function or a single-point parametric plot function a popup menu
will appear. In the menu there are five items available:
Edit
Selects the function in the Functions sidebar for editing.
Hide
Hides the selected graph. Other plots of the graph’s function will still be shown.
Remove
Removes the function. All its graphs will disappear.
Animate Plot...
Displays the Parameter Animator dialog.
Calculator
Opens the Calculator dialog.
Depending on the plot type, there will also be up to five tools available:
12
The KmPlot Handbook
Copy (x, y)
Copies the current value on the plot to the system clipboard. This tool can be useful for
creating tables of function values outside of KmPlot.
Copy Root Value
Copies the root x value to the system clipboard. Only up to the first five digits after the
decimal point can be copied. Use some computer algebra system to determine this root
with arbitrary precision. This tool is only available when the current tracking position is
close to a root.
Plot Area...
Select the minimum and maximum horizontal values for the graph in the new dialog that
appears. Calculates the integral and draws the area between the graph and the horizontal
axis in the selected range in the color of the graph.
Find Minimum...
Find the minimum value of the graph in a specified range. The selected graph will be
highlighted in the dialog that appears. Enter the lower and upper boundaries of the region
in which you want to search for a minimum.
Note: You can also tell the plot to visually show the extreme points in the Plot Appearance
dialog, accessible in the Functions sidebar by clicking on Advanced....
Find Maximum...
This is the same as Find Minimum... above, but finds the maximum value instead of the
minimum value.
13
The KmPlot Handbook
Chapter 4
Configuring KmPlot
To access the KmPlot configuration dialog, select Settings → Configure KmPlot... menu item.
The settings for Constants... can only be changed from the Edit menu and the Coordinate Sys-
tem... only from the View menu.
Here you can set global settings which automatic will be saved when you exit KmPlot. You can
set angle-mode (radians and degrees), zoom in and zoom out factors for zooming using Ctrl with
mouse wheel or the corresponding menu items, and whether to show advanced plot tracing.
14
The KmPlot Handbook
None
No gridlines are drawn on the plot area.
Lines
Straight lines form a grid of squares on the plot area.
Crosses
Crosses are drawn to indicate points where x and y have integer values (e.g., (1,1), (4,2)
etc.).
Polar
Lines of constant radius and of constant angle are drawn on the plot area.
Axis Labels
This section sets labels for the horizontal and vertical axes.
Axis widths:
Sets the width of the lines representing the axes.
Line width:
Sets the width of the lines used for drawing the grid.
Tic width:
Sets the width of the lines representing tics on the axes.
Tic length:
Sets the length of the lines representing tics on the axes.
15
The KmPlot Handbook
Show labels
If checked, the names of the axes are shown on the plot and the axes’ tics are labeled.
Show axes
If checked, the axes are visible.
Show arrows
If checked, the axes are displayed with arrows at their ends.
In the Coords section of the Colors configuration dialog, you can change the colors of the axes,
the grid and the background of the main KmPlot area.
The Default Function Colors control which colors are cycled through when creating new func-
tions.
16
The KmPlot Handbook
Axes labels:
The font used for drawing the axis numbers and x/y labels.
Diagram labels:
The font used for drawing diagram labels (e.g., those showing the plot name or extreme
points).
Header table:
The font used for drawing the header when printing a plot.
17
The KmPlot Handbook
Chapter 5
KmPlot Reference
name
The function name. If the first character is ‘r’ the parser assumes that you are using polar
coordinates. If the first character is ‘x’ (for instance ‘xfunc’) the parser expects a second
function with a leading ‘y’ (here ‘yfunc’) to define the function in parametric form.
var1
The function’s variable.
var2
The function ‘group parameter’. It must be separated from the function’s variable by a
comma. You can use the group parameter to, for example, plot a number of graphs from
one function. The parameter values can be selected manually or you can choose to have
a slider bar that controls one parameter. By changing the value of the slider the value
parameter will be changed. The slider can be set to an integer between 0 and 100.
term
The expression defining the function.
By default, the trigonometric functions work in radians. However, this can be changed via Set-
tings → Configure KmPlot... menu item.
18
The KmPlot Handbook
sqr(x)
The square xˆ2 of x.
sqrt(x)
The square root of x.
sign(x)
The sign of x. Returns 1 if x is positive, 0 if x is zero, or −1 if x is negative.
H(x)
The Heaviside Step Function. Returns 1 if x is positive, 0.5 if x is zero, or 0 if x is negative.
exp(x)
The exponent eˆx of x.
ln(x)
The natural logarithm (inverse exponent) of x.
log(x)
The logarithm of x to base 10.
abs(x)
The absolute value of x.
floor(x)
Rounds x to closest integer less than or equal to x.
ceil(x)
Rounds x to the closest integer greater than or equal to x.
19
The KmPlot Handbook
round(x)
Rounds x to the closest integer.
gamma(x)
The gamma function.
factorial(x)
The factorial of x.
min(x1 ,x2 ,...,xn )
Returns the minimum of the set of numbers {x1 ,x2 ,...,xn }.
max(x1 ,x2 ,...,xn )
Returns the maximum of the set of numbers {x1 ,x2 ,...,xn }.
mod(x1 ,x2 ,...,xn )
Returns the modulus (Euclidean length) of the set of numbers {x1 ,x2 ,...,xn }.
pi, π
Constants representing π (3.14159...).
e
Constant representing Euler’s Number e (2.71828...).
5.3 Extensions
An extension for a function is specified by entering a semicolon, followed by the extension, after
the function definition. The extension can be entered by using the D-Bus method ‘parser addFu
nction’. None of the extensions are available for parametric functions but N and D[a,b] work for
polar functions too. For example:
f(x)=x ^2; A1
will show the graph y=x2 with its first derivative. Supported extensions are described below:
N
The function will be stored but not be drawn. It can be used like any other user-defined or
predefined function.
A1
The graph of the derivative of the function will be drawn additionally with the same color
but less line width.
A2
The graph of the second derivative of the function will be drawn additionally with the same
color but less line width.
D[a,b]
Sets the domain for which the function will be displayed.
20
The KmPlot Handbook
P[a{,b...}]
Give a set of values of a group parameter for which the function should be displayed. For
example: f(x,k)=k*x;P[1,2,3] will plot the functions f(x)=x, f(x)=2*x and f(x)=3*x.
You can also use functions as the arguments to the P option.
Please note that you can do all of these operations by editing the items in the Derivatives tab, the
Custom plot range section and the Parameters section in the Functions sidebar too.
ˆ
The caret symbol performs exponentiation. e.g., 2ˆ4 returns 16.
*, /
The asterisk and slash symbols perform multiplication and division . e.g., 3*4/2 returns 6.
+, −
The plus and minus symbols perform addition and subtraction. e.g., 1+3−2 returns 2.
<, >, ≤, ≥
Comparison operators. They return 1 if the expression is true, otherwise they return 0. e.g.,
1 ≤ 2 returns 1.
√
√
The square root of a number. e.g., 4 returns 2.
|x|
The absolute value of x. e.g., |−4| returns 4.
±,
Each plus-minus sign gives two sets of plots: one in which the plus is taken, and one in
which the minus is taken.e.g.. y = ±sqrt(1−xˆ2) will draw a circle. These, therefore,
cannot be used in constants.
Note the precedence, which means that if parentheses are not used, exponentiation is performed
before multiplication/division, which is performed before addition/subtraction. So 1+2*4ˆ2
returns 33, and not, say 144. To override this, use parentheses. To use the above example, (
(1+2)*4)ˆ2 will return 144.
21
The KmPlot Handbook
22
The KmPlot Handbook
Constants can be used as part of an expression anywhere inside of KmPlot. Each constant must
have a name and a value. Some names are invalid, however, such as existing function names or
existing constants.
There are two options that control the scope of a constant:
Document
If you select the Document checkbox, then the Constant will be saved along with the cur-
rent diagram when you save it to file. However, unless you have also selected the Global
option, the constant will not be available between instances of KmPlot.
Global
If you select the Global checkbox, then the Constant’s name and value will be written to
KDE settings (where it can also be used by KCalc). The constant will not be lost when
KmPlot is closed, and will be available again for use when KmPlot is started again.
23
The KmPlot Handbook
Chapter 6
Command Reference
File → Export...
Exports the plotted graphs to an image file in all formats supported by KDE.
File → Print...
Opens print configuration window. Press the Options » button then choose the KmPlot
Options tab to configure options that are specific for KmPlot.
File → Print Preview
Shows the preliminary image of the current plot as printed on the current default printer.
Press the rightmost button on the toolbar of the print preview window to configure options
that are specific for KmPlot.
Edit → Constants...
Displays the Constants Editor dialog box. See Section 5.8.
N OTE
The mouse wheel can also be used as a zoom control. To zoom in or out using the mouse, hold down
the Ctrl key while you turn the mouse wheel. Each tick increases or decreases the zoom factor by the
value defined in the KmPlot General settings.
24
The KmPlot Handbook
Tools → Calculator
Opens the Calculator dialog.
Tools → Plot Area...
Select a graph and the values of the horizontal axis in the new dialog that appears. Calcu-
lates the integral and draws the area between the graph and the horizontal axis in the range
of the selected values in the color of the graph.
Tools → Find Minimum...
Find the minimum value of the graph in a specified range.
Tools → Find Maximum...
Find the maximum value of the graph in a specified range.
25
The KmPlot Handbook
Chapter 7
Scripting KmPlot
You can write scripts for KmPlot using D-Bus. For example, if you want to define a new function
f(x)=2sin x+3cos x, set its line width to 20 and then draw it, you type in a console:
qdbus [Link]-PID /parser [Link] ˝f(x)=2sin x+3cos x˝ ˝˝
As a result, the new function’s id number will be returned, or -1 if the function could not be
defined.
qdbus [Link]-PID /parser [Link] ID 20 This
command sets the function with the id number ID the line width to 20.
qdbus [Link]-PID /view [Link] This command repaints the
window so that the function get visible.
A list of the available functions:
26
The KmPlot Handbook
/maindlg [Link]
Opens the export dialog.
/maindlg [Link]
Opens the settings dialog.
/maindlg [Link]
Shows the predefined math functions in the handbook.
/maindlg [Link]
The same as choosing Tools → Minimum Value... in the menu.
/maindlg [Link]
The same as choosing Tools → Maximum Value... in the menu.
/maindlg [Link]
The same as choosing Tools → Plot Area... in the menu.
/maindlg [Link]
The same as choosing Tools → Calculator in the menu.
/parser [Link] f_str0 f_fstr1
Adds a new function with the expressions f_str0 and f_str1. If the expression does not
contain a function name, it will be auto-generated. The id number of the new function is
returned, or -1 if the function could not be defined.
/parser [Link] id
Removes the function with the id number id . If the function could not be deleted, false is
returned, otherwise true.
/parser [Link] id eq f_str
Sets the expression for the function with the id number id to f_str . Returns true if it
succeed, otherwise false.
/parser [Link]
Returns the number of functions (parametric functions are calculated as two).
/parser [Link]
Returns a list with all functions.
/parser [Link] f_str
Returns the id number of f_str or -1 if the function name f_str was not found.
/parser [Link] id
Returns true if the function with the ID id is visible, otherwise false.
/parser [Link].functionF1Visible id
Returns true if the first derivative of the function with the ID id is visible, otherwise false.
/parser [Link].functionF2Visible id
Returns true if the second derivative of the function with the ID id is visible, otherwise
false.
/parser [Link] id
Returns true if the integral of the function with the ID id is visible, otherwise false.
27
The KmPlot Handbook
28
The KmPlot Handbook
29
The KmPlot Handbook
Chapter 8
KmPlot
Program copyright 2000-2002 Klaus-Dieter Möller [Link]@[Link]
C ONTRIBUTORS
30