Copyright © 2000, 2001, 2002 Klaus-Dieter Möller
Copyright © 2003 Philip Rodrigues <phil@kde.org>
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
KmPlot is a mathematical function plotter for the KDE Desktop.
KmPlot is part of the KDE-EDU Project: http://edu.kde.org/
Table of Contents
KmPlot is a mathematical function plotter for the KDE Desktop. It has a powerful built-in parser. You can plot different functions simultaneously and combine them to build new functions.
KmPlot supports parametric functions and functions in polar coordinates. Several grid modes are supported. Plots may be printed with high precision in the correct scale.
KmPlot also provides some numerical an visual features like:
Filling and calculating the area between the plot and the first axis
Finding maximum and minimum values
Changing function parameters dynamically
Plotting derivatives and integral functions.
In the main toolbar there is a simple text box in which you can enter a function expression. Simply enter:
x^2
and press Enter. This will draw the plot of y=x^2 in the coordinate system. Enter another expression in the text box like 5*sin(x)
and another plot will be added. Click on one of the lines you have just plotted. Now the cross hair gets the colour of the plot and is attached to the plot. You can use the mouse to move the cross hair along the plot. In the status bar at the bottom of the window the coordinates of the current position is displayed. Note that if the plot touches the x-axis the root will be displayed in the status bar, too.
Click the mouse again and the cross hair will be detached from the plot.
Let us make some changes to the function and change the colour of the plot.
You can edit all functions with the -> menu entry. A dialogue appears which lists all the functions that you have plotted. Notice that KmPlot has automatically found a unique function name for your expressions and completed the expression to a function equation.
Select f(x)=x^2 in the list. A double click or pressing the button will show you a dialogue window. Here you have access to a lot of options. Let us rename the function and move the plot 5 units down. Change the function equation to
parabola(x)=x^2-5
Select another colour for the plot using the button. Finally press and your changes take effect in the coordinate system.
All changes can be undone until you press in the Edit Plots dialogue.
KmPlot deals with named functions, which can be specified in terms of Cartesian coordinates (called “explicit functions”), polar coordinates or as parametric functions. To enter a function, choose ->. You can also enter new functions in the Function equation text box in the main KmPlot window. The text box can handle explicit and polar functions. Each function you enter must have a unique name (i.e., a name that is not taken by any of the existing functions displayed in the list box). A function name will be automatically generated if you do not specify one.
For more information on KmPlot functions, see Chapter 5, KmPlot Reference.
To enter an explicit function (i.e., a function in the form y=f(x)) into KmPlot, just enter it in the following form:
f
(x
)=expression
Where: f
is the name of the function, and can be any string of letters and numbers you like, provided it does not start with any of the letters x, y or r (since these are used for parametric and polar functions).
x
is the x-coordinate, to be used in the expression following the equals sign. It is in fact a dummy variable, so you can use any variable name you like, but the effect will be the same.
expression
is the expression to be plotted, given in appropriate syntax for KmPlot. See the section called “Mathematical Syntax”.
As an example, to draw the graph of y=x2+2x, enter the following into the functions dialogue of KmPlot:
f(x)=x^2+2x
Parametric functions are those in which the x and y coordinates are defined by separate functions of another variable, often called t. To enter a parametric function in KmPlot, follow the procedure as for an explicit function, but prefix the name of the function describing the x-coordinate with the letter x, and the function describing the y-coordinate with the letter y. As with explicit functions, you may use any variable name you wish for the parameter. To draw a parametric function, you must go to . A function name will be created automatic if you do not specify one.
As an example, suppose you want to draw a circle, which has parametric equations x=sin(t), y=cos(t). In the KmPlot functions dialogue, do the following:
Open the parametric plot dialogue with ->.
Enter a name for the function, say, circle
, in the Name box. The names of the x and y functions change to match this name: the x function becomes xcircle(t) and the y function becomes ycircle(t).
In the x and y boxes, enter the appropriate equations, i.e., xcircle(t)=sin(t)
and ycircle(t)=cos(t)
.
You can set some further options for the plot in this dialogue:
If this option is selected, the plot is not drawn, but KmPlot remembers the function definition, so you can use it to define other functions.
If this option is selected, you can change the maximum and minimum values of the parameter t for which the function is plotted using the min and max boxes.
With this option you can set the width of the line drawn on the plot area, in units of 0.1mm.
Click on the colour box and pick a colour in the dialogue that appears. The line on the plot will be drawn in this colour.
Polar coordinates represent a point by its distance from the origin (usually called r), and the angle a line from the origin to the point makes with the x-axis (usually represented by the Greek letter theta). To enter functions in polar coordinates, use the menu entry ->. In the box labelled r, complete the function definition, including the name of the theta variable you want to use, e.g., to draw the Archimedes' spiral r=theta, enter:
(theta)=theta
so that the whole line reads “r(theta)=theta”. Note that you can use any name for the theta variable, so “r(foo)=foo” would have produced exactly the same output. Functions can be combined to produce new ones. Simply enter the functions after the equals sign in an expression as if the functions were variables. For example, if you have defined functions f(x) and g(x), you can plot the sum of f and g with:
sum(x)=f(x)+g(x)
Note that you can only combine functions of the same type, e.g. an explicit function cannot be combined with a polar function.
To change the appearance of a function's graph on the main plot window, select the function in the Edit Plots dialogue, and click on the button. In the dialogue which appears, you can change the line width in the text box, and the colour of the function's graph by clicking on the colour button at the bottom. If you are editing an explicit function, you will see a dialogue with three tabs. In the first one you specify the equation of the function. The Derivatives tab lets you draw the first and second derivative to the function. With the Integral tab you can draw the integral of the function which is calculated using Euler's method.
Another way to edit a function is to right click on the graph. In the popup menu that appears, choose
For more information on the popup menu, see the section called “Popup menu”.
When right-clicking on a plot function or a single-point parametric plot function a popup menu will appear. In the menu there are seven items available:
Hides the selected graph. Other plots of the graph's function will still be shown.
Removes the function. All its graphs will disappear.
Shows the editor dialogue for the selected function.
For plot functions the following four items are also available:
Opens a dialogue in which you can find the y-value corresponding to a specific x-value. The selected graph will be highlighted in the dialogue. Enter an x value in the X box, and click on (or press Enter). The corresponding y value will be shown under Y.
Find the minimum value of the graph in a specified range. The selected graph will be highlighted in the dialogue that appears. Enter the lower and upper boundaries of the region in which you want to search for a minimum, and click . The x and y values at the minimum will be shown.
This is the same as above, but finds maximum values instead of minima.
Draws the area between the graph and the x-axis. The selected graph will be highlighted in the new dialogue that appears. For more information on the Search for Area Under Graph-feature, see the section called “The Menu”.
To access the KmPlot configuration dialogue, select ->. A number of settings can also be changed from options in the menu, as well.
Settings changed in the KmPlot configuration dialogue become the default for KmPlot, and only take effect when a new plot is started. Settings changed in the menu take effect immediately, but do not persist after KmPlot is exited.
Here you can set global settings which automatic will be saved when you exit KmPlot. In the first tab you can set calculation-precision, angle-mode (radians and degrees), background colour and zoom in and zoom out factors.
The second tab let you define you own constants. KmPlot saves the constains in the same file as KCalc does. That means you can create a constant in KmPlot, close the program and load it in KCalc and vice versa. KmPlot only supports constant names that consist one capital character and if you in KCalc define a constant name that is not one character, the name will be truncated. E.g, if you already have the constants "apple" and "bananas" in KCalc, they will be renamed to "A" and "B" in KmPlot.
In the Coords tab of the Colours configuration option, you can change the colours of the axes and grid of the main KmPlot area.
In the Functions tab, you can change the colours used for the graphs of the ten functions allowed in KmPlot.
Sets the range for the x-axis scale. You can choose one of the predefined ranges, or select Custom to make your own. Note that in the Custom boxes, you can use the predefined functions and constants (see the section called “Predefined Function Names and Constants”) as the extremes of the range (e.g., set min: to 2*pi
). You can even use functions you have defined to set the extremes of the axis range. For example, if you have defined a function f(x)=x^2
, you could set min: to f(3)
, which would make the lower end of the range equal to 9.
Sets the range for the y-axis. See “X-Axis” above.
Sets the width of the lines representing the axes.
Sets the width of the lines representing tics on the axes.
Sets the length of the lines representing tics on the axes.
If checked, the names (x, y) of the axes are shown on the plot.
You can set the Grid Style to one of four options:
No gridlines are drawn on the plot area
Straight lines form a grid of squares on the plot area.
Crosses are drawn to indicate points where x and y have integer values (e.g., (1,1), (4,2) etc.).
Lines of constant radius and of constant angle are drawn on the plot area.
The Line width option is used to set the width of the lines of the grid.
For each axis, you can set the Scaling and Printing of one tic. The Scaling option selects how many units apart the axis tics will be (and therefore, how far apart grid lines will be drawn), and the Printing option selects the length of one tic when displayed on the screen or printed. In this way, these options can be used to change the size of the graph on screen or on a page: For example, doubling the Printing setting whilst keeping the Scaling setting the same will result in the graph doubling in in height or width.
Some syntax rules must be complied with:
name(var1[, var2])=term [;extensions]
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.
The function's variable
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.
The expression defining the function.
All the predefined functions and constants that KmPlot knows can be shown by selecting ->. They are:
Return the square and square root of a number, respectively.
Return the exponential and natural logarithm of a number, respectively.
Returns the logarithm to base 10 of a number.
Return the sine and inverse sine of a number, respectively. Note that the argument to sin and the return value of arcsin are in radians.
Return the cosine and inverse cosine of a number, respectively. Also in radians.
Return the tangent and inverse tangent of a number, respectively. Also in radians.
Return the hyperbolic sine and inverse hyperbolic sine of a number, respectively.
Return the hyperbolic cosine and inverse hyperbolic cosine of a number, respectively.
Return the hyperbolic tangent and inverse hyperbolic tangent of a number, respectively.
Return the sine and inverse sine of a number, respectively. Note that the argument to sin and the return value of arcsin are in radians.
Return the cosine and inverse cosine of a number, respectively. Also in radians.
Constants representing π (3.14159...) and e (2.71828...), respectively.
These functions and constants and even all user defined functions can be used to determine the axes settings as well. See the section called “The Axes Configuration”.
KmPlot uses a common way of expressing mathematical functions, so you should have no trouble working it out. The operators KmPlot understands are, in order of decreasing precedence:
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.
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.
By default, explicitly given functions are plotted for the whole of the visible part of the x-axis. You can specify an other range in the edit-dialogue for the function. For every pixel on the x-axis KmPlot calculates a function value. If the plotting area contains the resulting point it is connected to the last drawn point by a line.
Parametric functions are plotted for parameter values from 0 up to 2π. You can set the plotting range in the dialogue for the function too.
While the mouse cursor is over the plotting area the cursor changes to a cross hair. The current coordinates can be seen at the intersections with the coordinate axes and also in the status bar at the bottom of the main window.
You can trace a function's values more precisely by clicking onto or next to a graph. The selected function is shown in the statusbar in the right column. The cross hair then will be caught and be coloured in the same colour as the graph. If the graph has the same colour as the background colour, the cross hair will have the inverted colour of the background. When moving the mouse or pressing the keys Left or Right the cross hair will follow the function and you see the current x- and y-value. If the cross hair is close to y-axis, the root-value is shown in the statusbar. You can switch function with the Up and Down keys. A second click anywhere in the window or pressing any non-navigating key will leave this trace mode.
Note that tracing is only possible with explicitly given functions. The coordinates are always displayed according to a Cartesian system of coordinates. Neither non-single-point parametric functions nor functions given in polar coordinates can be traced in this way.
Starts a new Plot by clearing the coordinate system and resetting the function parser.
Opens an existing document.
Saves the document.
Saves the document under another name.
Sends the plot to a printer or file.
Exits KmPlot.
Displays the Colour Settings dialogue box. See Chapter 4, Configuring KmPlot.
Displays the Coordinate System dialogue box. See Chapter 4, Configuring KmPlot.
Displays the Scaling Settings dialogue box. See Chapter 4, Configuring KmPlot.
Displays the Font Settings dialogue box. See Chapter 4, Configuring KmPlot.
Show both positive and negative x- and y-values on the grid.
Show positive and negative y-values, but positive x-values only
Show only positive x- and y-values.
Opens the dialogue for creating a new function plot. See Chapter 3, Using KmPlot.
Opens the dialogue for creating a new parametric plot. See Chapter 3, Using KmPlot.
Opens the dialogue for creating a new polar plot. See Chapter 3, Using KmPlot.
Displays the functions dialogue. There you can add, edit and remove functions. See Chapter 3, Using KmPlot.
The first five items in the menu change zoom-mode.
Disable the zoom-mode.
Let the user draw a rectangle. The minimum and maximum values will be set to the coordinates of the rectangle.
The minimum and maximum values will come closer to each other and the selected point in the graph will be centred.
The minimum and maximum values will be more separated from each other and the selected point in the graph will be centred.
The selected point in the graph will be centred.
The scale will be adapted to trigonometric functions. This works both for radians and degrees.
Toggle on and off the display of the toolbar. The default is on.
Toggle on and off the display of the statusbar at the bottom of the KmPlot main window. The default is on.
Personalise the keybindings for KmPlot.
Personalise the toolbars for KmPlot.
Customise KmPlot. The options available to you are described in Chapter 4, Configuring KmPlot.
This menu constains some tools for the functions that can be useful:
Let the user get the y-value from a specific x-value. At the moment, only plot functions are supported. Type a value or expression in the textbox under "X:". In the list below all the available functions are shown. Press the "Calculate" button to find the function's y-value. The result will be shown in the y-value box.
KmPlot has a standard KDE as described below, with one addition:
Opens a window with a list of the predefined function names and constants that KmPlot knows.
The standard KDE entries are:
Invokes the KDE Help system starting at the KmPlot help pages. (this document).
Changes the mouse cursor to a combination arrow and question mark. Clicking on items within KmPlot will open a help window (if one exists for the particular item) explaining the item's function.
Opens the Bug report dialogue where you can report a bug or request a “wishlist” feature.
This will display version and author information.
This displays the KDE version and other basic information.
If you want to contribute to KmPlot feel free to send a mail to (kd.moeller AT t-online.de)
or (f_edemar AT linux.se)
KmPlot
Program copyright 2000-2002 Klaus-Dieter Möller (kd.moeller AT t-online.de)
Contributors
CVS: Robert Gogolok (mail AT robert-gogoloh.de)
Porting GUI to KDE 3 and Translating: Matthias Messmer (bmlmessmer AT web.de)
Various improvements: Fredrik Edemar (f_edemar AT linux.se)
Documentation copyright 2000--2002 by Klaus-Dieter Möller (kd.moeller AT t-online.de)
.
Documentation extended and updated for KDE 3.2 by Philip Rodrigues (phil AT kde.org)
.
Documentation extended and updated for KDE 3.3 by Philip Rodrigues (phil AT kde.org)
and Fredrik Edemar (f_edemar AT linux.se)
.
Andrew Coles(andrew_coles AT yahoo.co.uk)
This documentation is licensed under the terms of the GNU Free Documentation License.
This program is licensed under the terms of the GNU General Public License.
KmPlot is part of the KDE project http://www.kde.org/.
KmPlot can be found in the kdeedu package on ftp://ftp.kde.org/pub/kde/, the main FTP site of the KDE project.
KmPlot is part of the KDE EDU Project: http://edu.kde.org/
KmPlot has its own homepage on SourceForge. You can also find archives of older versions of KmPlot there, for example, for KDE 2.x
In order to compile and install KmPlot on your system, type the following in the base directory of the KmPlot distribution:
%
./configure
%
make
%
make install
Since KmPlot uses autoconf and automake you should have no trouble compiling it. Should you run into problems please report them to the KDE mailing lists.
Would you like to make a comment or contribute an update to this page?
Send feedback to the KDE Docs Team