Set Column Values

This dialog is activated with the Set Column Values... command from the Table menu or by entering the shortcut Alt-Q. It provides for filling a column with the result of a function evaluation.

If the option Display formulas in header is checked, the custom functions defined for all columns will be shown in the table header. This feature can be enabled by default via the Tables tab from the Preferences dialog by checking the option F(x) in the Display group box.

The available mathematical functions can be viewed with the help of the function selector button which displays the capital greek letter sigma ∑. By pressing this button a dropdown menu of intrinsic functions grouped by the first letter of their name will be shown. Selecting a function name will copy it into the function definition pane. Details of these functions and supported mathematical operators are listed in the muParser section in the chapter on Mathematical Expressions and Scripting. Also a tool tip for function syntax is displayed by double-clicking an inserted function name while keeping the left button of the mouse pressed.

The special function, col(c), is used to access the values of column c, where c is the column's number (as in col(2)) or its name in double quotes (as in col("time")). You can also obtain values from other tables using the tablecol(t,c) function, where t is the table's name in double quotes and c is the column's number or its name in double quotes (example: tablecol("Table1","time")).

The variables i and j can be used to access the current row and column numbers. Similarly, sr and er represent the selected starting and ending row, respectively.

Using Python as scripting language gives you even more possibilities. Not only can you use arbitrary Python code in the function body, but also access other objects within your project. The current table can be accessed using the self key word, like in the script example bellow. The script fills the first column of the table with ascending values and all other columns with random values:

for i in range(2, self.numCols() + 1):
	c = self.column(i)

For more details on the Python API available in QtiPlot, see the section on Python in the chapter on Mathematical Expressions and Scripting. Nevertheless, even though Python allows for a more powerful syntax, it can be quite slow for very large tables. Therefore you might want to use muParser instead, even when Python is set as the default script engine for your current project. Checking the Use built-in muParser option will force the use of muParser as the scripting engine. This greatly increases the speed of the evaluation for single line expressions.

Figure 5-188. The Set Column Values... dialog.

The status bar at the bottom of this dialog displays the current Position of the editing cursor as well as any error messages that might occur during the evaluation of the user provided function.

Warning: When you make changes to the values in a table which contains "filled" values, the dependent values are not recomputed unless the Automatically Recalculate Column Values option is checked in the Tables tab of the Preferences dialog. If this option is unchecked, you will have to explicitly tell QtiPlot to recalculate individual cells or whole columns or rows by selecting "Recalculate" from their context menu or by pressing Ctrl-Return.