Scalar Field

A scalar field is a representation of a 2-D array of numbers, using colors to represent the numerical values, sometimes referred to as a heat map. The values can be represented using discrete colors as a continuous, smoothed surface (i.e, 2D interpolation).

Input Data

To create a scalar field, you need to provide data that corresponds to a two-dimensional regular grid. There are three types of grids that you can represent:

  • Cartesian Grid – Uniform spacing, rectangular shapes
  • Rectilinear Grid – Non-uniform, rectangular shapes
  • Curvilinear Grid – Comprised of four-sided polygons

Here is an example of each type of grid. Despite the different shapes, each grid contains the same number of cells.

Numerical Axes

By default, the Scalar Field command requires three columns of data, two columns provide the x and y grid location and the third column is used to color the cells. For example, consider a data set with three columns, x, y, and z. The values for x and y form a 3 by 3 uniform grid.

This creates a simple scalar field, where the color of each square is based on the value of z. By default, the colors are set to a continuous color ramp, from black to white. Turn on the hover (⇧⌘H) to view the corresponding value for each square.

Categorical Axes

The x or y columns can be a Number, Text, or Date column. When a Text column is used, the data are grouped according to each unique entry and ordered alphabetically.

Here, the ‘x’ and ‘Amount’ columns are the same, but y is replaced with a text column called ‘Group’.

The axis style now shows as categorical (tick marks between categories) and the ‘A’ data is in the first y location.


The Layout menu has several options for specifying the (x, y) locations.

  • Flattened (default)
  • Uniform
  • Non-Uniform


The default Layout of the data is ‘Flattened’. Input data for Cartesian or Rectilinear grid types.

A flattened or long format has all the values in one column, as opposed to a wide format where the values are stored across multiple columns.

For the Scalar field command, the data must be in a long or flattened format. If your data is not already in a long format, the program has a feature to flatten columns. For instructions on how to reformat data from a wide to long format see: How to ‘Flatten’ Data.


When the Layout is set to ‘Uniform Row’ or ‘Column’, the x-y grid locations are specified using the following input:

  • Origin – The bottom left corner of the grid (x, y).
  • Size – The dimensions of the grid (m, n).
  • Step – The distance between each grid point.
  • Order – Row or column first.

As before, the Values must be in one column.

Here we set the origin to x = 1 and y = 4. The step size is 1 and the grid is 3 by 3.

When the Order is set to ‘Row first’ the cells are filled horizontally (x-direction).

When the Order is set to ‘Col first’ the cells are filled vertically (y-direction).

Non Uniform

When you set Layout to ‘Non Uniform’, you can specify uniform, rectilinear, or curvilinear grids.

List of x/y

By default, the ‘Non Uniform’ option expects two lists of x and y values. These are the unique values of each that make up the grid. Rather than having to list them all out, you can specify the unique values of each. Using the Order, you can vary the order of the values (Row or Column first).

For example, you can specify a rectilinear grid with the following data.

Here is the resulting graph.

If the lists of x and y values were evenly spaced, the grid would be uniform.


When you have all of the values for x and y in a column, you can change the Type to ‘Array’. For example, curvilinear grids will not have the repeating x and y values and would need to be drawn using this approach.

For example, here we have calculated an x and y value given a radius r and angle theta.

The values are calculated using:

  • theta = π/4* mod(#-1,3)
  • x = r*cos(theta)
  • y = r*sin(theta)+1

In the command, the x and y columns are input as before, but here you must change the Type to ‘Arrays’ and also provide the grid size.

See the resulting graphic below where the grid locations are located at the red points.


Expand the command to see the color options. There are several built-in color ramps to choose from or you can create your own custom Color ramp. Use the Ramp menu to select a custom color ramp. Use the Specific menu to choose a different built-in ramp. To the right of the Specific menu, specify the minimum and maximum values in the ramp. By default, they are based on the range of the Values (minV, maxV).

There is Refine below the Ramp menu. By checking this box, the values will be interpolated between each grid, resulting in a smooth, continuous representation of the data.

Color ramp Legend

To display the color ramp used in the scalar field, add a Color Ramp Legend to your graphic

You can use the menus on the Color Ramp Legend command, or click and drag the scalar field object onto the Command menu.

Grid and Values

The Scalar Field command also has the option of showing a grid, and the ability to display a label for each value. This graph has both the Grid and Values checked. The Border helps to ensure that text can be read on light or dark backgrounds.


Select the Contours check box to draw contour lines.

You will also have to expand this section and specify the location of the contours. Use the Contours menu to either select a column that contains the numerical values where you want to draw contours or select ‘List’ and type the values in, as shown below.

In the above example, the Draw Values checkbox is selected, labeling the contours at intervals along the line. You can customize the distance between the labels in units of measure. If you type only a number in this box, the value is interpreted as pixels or specify mm, cm, or in.


Scalar field command can also output data from the gear menu, including X-Y Grid Locations and contour location and values.

  • Regular Uniform
  • Non-uniform Rectilinear
  • Curvilinear Grid

Download the example files to see how the following graphs are made.


Volcano Data

The Scalar Field is used to draw example topographic data from the dataset, volcano (sample dataset in R). Contours are also added along with a Color Ramp Legend.

DataGraph Examples: CONTOUR LINES & COLOR RAMPS. Access by opening DataGraph.

Uniform Grid

The Scalar Field is used to represent a 10×10 uniform grid of data in three columns (x,y,z). A Color Ramp variable provides the color.

Download: Scalar-Field–XYZ-with-Labels.dgraph

Uniform vs. Non-uniform

The Scalar Field is used to represent a column of numbers on a uniform (Cartesian) and a non-uniform grid (rectilinear). Each image below uses the same data (z-direction), but the data are mapped to different x-y locations.

Download: Scalar-Field–Vary-Layout.dgraph

Random Field

The Scalar Field is demonstrated for a random field of 100×100 uniform grid size (x,y, and z data). A Color Ramp Legend is also displayed on the graph.

Download: Scalar-Field–Random-with-ColorRamp.dgraph

Logarithmic Data

The Scalar Field is used to visualize a randomly sampled, log-uniform distribution. To do this, the Color Ramp variable Transition menu is set to ‘Logarithmic’ to appropriately represent the data.

Download: Scalar-Field–Logarithmic-Scale.dgraph

Microarray Data

The Scalar Field command is used to visualize a microarray data set. In this case, ‘y’ is a text column (categorical variable) and the text is used to label the y-axis.

Download: Scalar-Field–Microarray-Data.dgraph


The Scalar Field command is used to create a square grid, represent values using a Color ramp, and draw contours. The grid is also mapped into other shapes (circle, twist, cone).

Download: Scalar-Field–Trippy.dgraph

Table of Contents