# Common Tasks

This chapter contains instructions for performing basic tasks with &kst;. It runs through the method for performing each task in the simplest way. Links to the sections of the handbook with more in-depth information are also given.

## Plotting Simple Graphs

How to plot a simple points-on-a-grid graph

The first thing you'll want to do with &kst; is probably to plot a simple graph. Here's the procedure:

1. Choose your data file. &kst; will read many types of data file, the simplest being a plain text (ASCII) file with the data in columns. For definiteness, we'll use the data file from , with the filename `simpledata.dat`.

2. Open &kst;. You are presented with the QuickStart dialog:

   The QuickStart dialog The QuickStart dialog

   Click on Data Wizard, and, in the wizard that appears, select your data file using the Open File button: .

3. The Next page is where you select which data to use. Column 2 in the data file contains the y-axis values, so tick the box next to 2 in the Field/Column list on the left-hand side. The INDEX field is a special field created by &kst;, but we won't be using it for this example.

4. Under Plot Types, leave the default XY as it is, but change the X axis vector to 1.

5. On the next page, we'll just change one thing: under Curve Style, select Points only to draw just the data points, and not lines joining them.

6. Click on Finish and you're done! The new plot appears in the main &kst; window.

## Curve Fitting

&kst; also provides functions for many different types of curve fitting: linear, quadratic, sinusoidal, and more. As an example, we'll do a simple polynomial fit to the curve we plotted previously, in .

1. With the plot done, open the plugins dialog from Data New Plugin .

2. The Plot selection combo box contains all the &kst; fitting plugins, and more. Since the example data here are quadratic, we'll use the Fit polynomial plugin. Select the X Array and Y Array vectors for the fit – if you used the default names when producing the plot, select V0-1 for the X Array and V1-2 for the Y Array.

3. As it happens, the Order of the polynomial is set to 2 by default, which is what we want. You can set the Order to any integer, one of the predefined scalar quantities, or some statistical value based on one of the available vectors (for example, V1-2-Mean).

4. Hit OK to generate the values.

That's all we need to do to generate the values, so now we need to look at the output of the fitting process. Select Data View Fit Results from the menus, and the fit values are shown in the dialog which appears: the coefficients for x^2, x^1 and x^0 (the constant), along with the chi-squared value and the covariances between the coefficients.

The curve generated by the fitting is not automatically superimposed on the data points. To do this, use the New Curve dialog by selecting Data New Curve... . For the X axis vector, select V0-1 (if you've been using the automatically generated names), and for the Y axis vector, choose P1-kstfit_polynomial_unweighted-Y Fitted. Click on OK once you've set any other options that you want. The curve is plotted in its own window: for this example, we don't want that, so delete the new plot by right-clicking on it and choosing Delete in the popup menu that appears.

Now, to add the curve fit to the data plot, open the Plot dialog from Plots Edit Plot... . On the Content tab that appears, the vector containing the fit data is shown under Available objects. Select this vector, and add it to the Displayed objects list by clicking on the left arrow button. Click on Apply Edits, and then Close, and you're finished.

## Plotting a Power Spectrum

&kst; makes plotting power spectra extremely easy. There are two ways to do this: with the Data Wizard, or by creating a power spectrum from an existing vector.

### Power spectra with the Data Wizard

This is almost the same as plotting a simple graph. Here are the full instructions:

Open the Data Wizard and select your data file using the Open File button:

.

1. The Next page is where you select which data to plot the power spectrum of. Column 2 in the data file contains the y-axis values, so tick the box next to 2 in the Field/Column list on the left-hand side.

2. Under Plot Types, select Power spectrum. There are also some options specifying how the power spectrum is calculated, which we'll leave as defaults in this example.

3. On the Next page, the options specific to a power spectrum are found under Power Spectrum Axis Mode. The x and y axes can both be made logarithmic here.

4. Click on Finish and you're done! The new plot appears in the main &kst; window.

### Power Spectra from an existing plot

Using the `simpledata.dat` example from , we can do the following to produce its power spectrum:

1. Open the Power Spectrum dialog from Data New Power Spectrum....

2. From the Data vector combo box, choose the vector representing your data. In our `simpledata.dat` example, the required vector is called V1-2.

3. Click on OK and the power spectrum is displayed in a new plot.

## Using &kst; from the Command Line

The command line switches to perform the tasks above