See related video:Contour Plots and Color Mapping
Contour graphs are surface graphs plotted in 2D space. Viewing a contour graph is the same as viewing a 3D surface graph from a vantage point perpendicular to the XZ plane. In contour graphs, ranges of Z values are distinguished by different colors or levels of gray scale, labeled contour lines, or both.

Origin provides seven contour graph types:
| Graph Type | XYZ Columns in Worksheet | Matrix Window | Virtual Matrix in Worksheet |
|---|---|---|---|
|
Yes (except Heatmap) | Yes | Yes |
|
Yes | Yes | No |
|
Yes | No | No |
The (Plot Details) Color Map/Contours and Label tabs provide controls for editing your contour graphs.
Note that a contour plot in Origin can be created from matrix data, worksheet data, or virtual matrix data. Creating a contour plot from a matrix is faster than creating a contour plot directly from a worksheet, so the matrix method is suitable for large data. On the other hand, creating a contour plot directly from XYZ worksheet data uses a triangulation method to generate the contour lines, and there is no need to generate a matrix.
| Note: A contour triangulation algorithm that plots raw X and Y data was implemented for Origin 2016. Previous versions performed some normalization of X and Y data before plotting. Thus, contour and 3D surface plots of XYZ worksheet data, created in version 2016 and higher, may differ from plots of the same data created in earlier versions. This change will be most noticeable if there are large scale range differences between X and Y values. See FAQ-822 for more information. |
Other advantages to creating contour graphs from XYZ worksheets:
Contour graphs created from XYZ data or a virtual matrix support nonlinear X/Y axes while those from a matrix window only support linear axes.
Prior to Origin 2018, the application of a custom boundary sometimes generated an imperfect fill at boundary margins. This has been improved in 2018. The user can restore the previous contour-fill behavior using system variable @TCSM. |
To create a Contour graph from matrix data, click the appropriate graph button or select the appropriate option in the Plot menu. To create a Contour graph from XYZ data, select a Z column or select no columns and pick one of the two above methods. To create a graph from virtual matrix data, you must select all the source data in your worksheet and use one of the two above methods which will open a dialog which will create the internal virtual matrix and graph. For more details about creating graphs from virtual matrices, please refer to Creating 3D and Contour Graphs from Virtual Matrix. We also explain each Contour graph type in detail in Contour Graphs.
Customizations of Contour graphs are handled by the Axis dialog and the Plot Details dialog. You can get more details about the Axis dialog from Graph Axes. To get more details about the Plot Details dialog, please refer to Customizing Your Graph.
There are some special features of contour graphs.
Once you created a contour plot from XYZ data, you can right click on the contour plot and select Extract Data Points to open Extract Data Points: xyzgrid dialog. Then you can specify the grid sizes and ranges along X and Y directions/ specify X and Y from Columns/ pick up points in the contour, and then output the interpolated data at specified grid points in either XYZ or matrix form to a new book.
The values for the specified grid points are computed by triangulation and line interpolation as described in algorithm section.
Note that contour values outside input data range will be set as missing values.
| Data Point | Specify the methods to extract data points.
|
|---|---|
| X Grid Size | When choose extract data points by Grids, specify the number of grid points along X direction. |
| Y Grid Size | When choose extract data points by Grids, specify the number of grid points along Y direction. |
| Grid Range | When choose extract data points by Grids, specify the boundary of the input data range. By default, all data points are included. In order to exclude bad or unwanted data points, you can restrict the input data range by editing the minimum and maximum XY coordinates (Note: Contour values outside input data range will be treated as missing values.).
|
| Output to | Specify the output data form:
|
| Input | When choose extract data points by Columns, specify the columns of X and Y range for extracting the corresponding Z value. |
| Output to | Specify the output data to:
|
| Pick | When choose extract data points Pick from Graph, click this Pick button, and then double-click on the graph to select the points you want to extract. Then click Done button, it will extract the XYZ of the points in a new sheet. |
Once you created a contour plot from virtual matrix or matrix, you can right click on the contour plot and select Extract Data Points to open Extract Data Points: mgrid dialog. Then you can specify the grid sizes and ranges along X and Y directions/ specify X and Y from Columns/ pick up points in the contour, how to treat the missing values, and output the interpolated data at specified grid points in matrix form to a new book.
| Data Point | Specify the methods to extract data points.
|
|---|---|
| X Grid Size | When choose extract data points by Grids, specify the number of grid points along X direction. |
| Y Grid Size | When choose extract data points by Grids, specify the number of grid points along Y direction. |
| Grid Range |
When choose extract data points by Grids, specify the boundary of the input data range. By default, all data points are included. In order to exclude bad or unwanted data points, you can restrict the input data range by editing the minimum and maximum XY coordinates (Note: Contour values outside input data range will be treated as missing values.).
|
| Missing Value Pretreatment | Specify the method to preprocess missing values when generate grid data with interpolation.
|
| Input | When choose extract data points by Columns, specify the columns of X and Y range for extracting the corresponding Z value. |
| Output to | Specify the output data to:
|
| Pick | When choose extract data points Pick from Graph, click this Pick button, and then double-click on the graph to select the points you want to extract. Then click Done button, it will extract the XYZ of the points in a new sheet. |


To remove (hide) contour labels:
Extract Contour Lines outputs the Z value, the XY coordinates and the area enclosed by the contour, to a new worksheet. The area calculation is done by the Polygon Area (polyarea) X-Function. Polygon Area returns the area enclosed by a given contour (Z value). There is no subtraction of the area within included contours.
To extract contour lines:
... then, right-click on your selection and choose Extract Contour Lines. Contour data, including contour area, are output to a new workbook.
Contour plots can be created directly (without gridding) from (x, y, z) coordinates (Cartesian coordinates) or (r,
, z) coordinates (cylindrical coordinates). If your data are in (r,
, z) coordinates, Origin first converts the data to XYZ space before making the contour plot. Conversions between (x, y, z) and (r,
, z) coordinates are expressed as:
and...

In Cartesian space, creating a contour plot is a four step process:
All data points are connected to create Delaunay triangles in the XY plane. The triangles are constructed so as to make them as equiangular as possible. In addition, no two triangles should intersect. Note that any side is shared by two adjacent triangles, unless it is located at the edge of the mesh.

To find the intersection points of the contour lines and the triangle sides:
Given a contour level zc, Origin traverses all the triangles to see whether or not the contour line for this level intersects with the triangle sides. If a triangle side has intersection with the contour line, it will be marked as a characteristic side. The coordinates of the intersection point, which will be referred to as a characteristic point in this document, will be computed with linear interpolation.
For a triangle side that connects two triangle vertices: I(xi, yi, zi) and J(xj, yj, zj), we will examine whether the following is true:
If it is true, we will say that this side is a characteristic side. Furthermore, if the product on the left of the inequality is zero, it will mean that the contour line passes through at least one of the vertices. In this case, zi and zj will be adjusted by subtracting a small value,
, so as to make sure that the characteristic point will not be a vertex. The adjustment is as follows:
where
.

If this side is a characteristic side, the coordinates of the characteristic point on it can be computed by linear interpolation in the following way:
Origin keeps records of all the characteristic sides and the coordinates of the characteristic points for future use.
Note that if a triangle intercepts the contour line, it will have exactly two characteristic sides.
To draw a contour line, we have to trace all the characteristic points on it.
If there is a characteristic point on the boundary of the triangular mesh, the tracing will start from that point. Otherwise, the tracing will begin with a random characteristic point.
Recall that a triangle that intercepts the contour line must have exactly two characteristic sides, and that a side which is not on the edge of the mesh must be shared by two triangles. Therefore, the tracing can go from one characteristic side (Side A in the following figure) to the other characteristic side of the same triangle (Side B in the following figure). If the latter is not on the edge of the triangular mesh, we will certainly find another triangle (Triangle 2 in the following figure) which shares this side with the current triangle (Triangle 1 in the following figure). Then we can find the characteristic point on the other characteristic side (Side C in the following figure) of this new triangle. In this way, the tracing continues until the edge of the mesh or a characteristic point which has already been traced is reached. (In the former case, the contour line is open; while in the latter case, it is closed.) Then the number of characteristic points that have been traced is compared with the total number of characteristic points for this level. If they are not equal, it will mean that there are still some characteristic points which have not been traced. The tracing will go on until all characteristic points have been traced.

After the tracing, the characteristic points are connected with straignt lines. Then smoothing is available for Contour from a Worksheet when the Smoothing checkbox in Plot Details dialog Contouring Info tab is ticked. You can read the imformation about smoothing parameters and the TPS algorithm, which is used for Contour from a Worksheet.

Creating a contour from matrix (or virtual matrix) has a similar but simpler algorithm, there are only three steps:
In which the linear interpolation, drawing of contour lines are just the same as the algorithm to create contour from workbook as explained above.
As for the line connection, when creating contour from matrix, the characteristic points are connected with straight lines. And no smoothing is performed afterwards.
Reference: