Adding Data

There are three different types of data items in Graphs:

  • Dataset : Data imported from a file or database.

  • Generated Dataset : Data generated from an equation over a fixed set of points.

  • Equation : A mathematical expression rendered continuously across the entire canvas.

Dataset

A dataset is data imported from an external source. Graphs supports column-based files (such as .csv, .dat, .xy, and plain text), spreadsheets (.ods and .xlsx), SQLite database files, Panalytical .xrdml files, and Leybold .xry files. Data from other Graphs projects can also be imported by selecting a project file.

To import data, press the Add button in the top left of the sidebar and choose Add Data from File…. Multiple files can be added in a single import session by using the add button in the top left of the import dialog. Each file appears in the sidebar of the dialog, where it can be selected to review and adjust its settings. Graphs will attempt to guess the appropriate settings for each file automatically. Once everything looks right, press Import to add all files to the project.

The Import Mode determines how a file is parsed, and is set automatically based on the file type. The available modes are described below.

Column-based Files

Column-based files store data as rows of values separated by a delimiter such as a comma, tab, or whitespace. Graphs detects the delimiter automatically in most cases. When using a custom delimiter, an extra field appears where a delimiter of your choice can be entered. This field recognizes regular expressions. Using \s+ matches any amount of whitespace including tabs, for example, and is equivalent to the default Whitespace option.

If a file only contains a single column of Y values, the Single Column option can be enabled to generate X values automatically from a configurable equation, where n represents the row index starting from zero. For example, n produces 0, 1, 2, 3… while n*0.5 produces 0, 0.5, 1.0, 1.5…

Spreadsheets

Graphs supports importing data from .ods and .xlsx spreadsheet files. The X and Y columns are selected by their alphabetical column index, starting from zero. As with column-based files, the Single Column option can be used to generate X values automatically when only Y data is available. Multiple items can be configured from the same spreadsheet in a single import session by using the Add Item button, each with its own column selection.

Databases

SQLite database files are also supported. When importing a database file, the available tables are shown in a dropdown. Once a table is selected, the X and Y columns can each be chosen from the numeric columns available in that table. If a table contains no numeric columns, a warning is shown.

Error Bars

Datasets support optional X and Y error bars. For spreadsheet and database imports, error bars can be enabled per axis using the corresponding toggle, after which an additional column selector appears to specify which column contains the error values. Column-based file formats that natively include error bar data, such as .xrdml files, will have them imported automatically.

Once imported, error bars are preserved through most operations. When combining multiple datasets, error bars are carried over only if all selected items have them in the output.

Generated Datasets

Generated datasets create data by evaluating an equation over a range of X values. To add one, press the Add button in the sidebar and choose Generate Data…. The following parameters can be configured:

Equation

The mathematical expression to evaluate, using x as the variable.

X Start and X Stop

The lower and upper bounds of the x-range to generate data over.

Steps

The number of data points to generate.

Scale

Determines the spacing between data points. Linear spacing places points at equal intervals. Other options such as Logarithmic, Square Root, and Inverse are useful when the data or the axis it will be plotted on follows a non-linear scale.

Generated datasets are treated the same as imported data for most purposes. However, unlike a regular dataset, the parameters used to generate the data can be changed at any time from the item editor, and the data will be regenerated accordingly.

Equation

Equation items render a mathematical expression directly and continuously across the entire canvas. To add one, press the Add button in the sidebar and choose Add Equation…, or press Ctrl+Alt+N.

The expression uses x as the variable. Most commonly used mathematical syntax is accepted. For example, a simple quadratic can be entered as x²+5, and expressions like sin(x)*x or 1/(x+1) work as expected. Trigonometric functions use radians by default. To use degrees instead, add a d to the function name. Using cosd(x) will use degrees while cos(x) uses radians.

One important distinction between equation items and datasets is that operations are performed analytically rather than numerically. For instance, taking the derivative of x²+5 produces the equation 2·x rather than a set of numerically computed slope values.