6.8.2 Contour Plots and Color MappingContour-Color-Map
Summary
Origin offers rectangular, polar, and ternary contour plots. For rectangular contour plots, the data can be either in a matrix or in a worksheet in XYZ format. Polar contour plots can be generated from three columns of data in a worksheet, organized either as R Z or R Z. Ternary contour plots can be generated from worksheet data organized in X Y Z Z format where the 2nd Z-column contains the 4th parameter which is the height value at a given XYZ point in the ternary space.
Many options are available for customizing contour plots, such as setting different major and minor contour levels, displaying contour lines only at major levels, applying color palettes, and also control for a custom boundary in the case of contour plots created directly from the worksheet.
What You Will Learn
This tutorial will show you how to:
- Set values in a Matrix and create a Contour Plot
- Customize levels, lines, and color mapping
- Extract data from contour lines
- Create a Contour Plot directly from XYZ data
- Use a Custom Boundary
Create Contour Plot from Matrix
- To create a new matrix click the New Matrix button . Move the cursor to the upper left corner of the matrix until the shape of the pointer changes as in the following image and click to select the entire matrix.
To set the dimensions, right-click and select Set Matrix Dimension/Labels in the context menu. On the XY Mapping tab, change setting as shown below .
- Input data into the matrix by highlighting it and right-clicking. Select Set Matrix Values in the context menu to open the Set Values dialog. Type i*sin(x) - j*cos(y) in the Formula edit box and click the OK button to generate data. The matrix should look like this:
- Each data point in the matrix corresponds to two different kinds of indices. One is the column and row indices. The other is the X and Y coordinates. Select View: Show X/Y from the main menu to see the X, Y coordinates:
- You can also select View: Image Mode to show the image form of the matrix:
- Select View: Data Mode to exit the image mode. Create a contour plot by activating the matrix and selecting Plot > Contour: Contour - Color Fill. The graph should appear as shown below:
Customize Levels, Lines and Color Map
Origin makes it easy to customize every aspect of the contour plot, including the color scale and adding labels:
- Active Graph1, and select Graph: Speed Mode menu to open the dialog. Set Speed Mode = Off and click OK"'
- Click on the Contour plot in Graph1, and then click on the Set Levels button on the pop-up Mini Toolbars. In the Set Levels dialog, click the Find Min/Max button and set Major Levels to 8 and Minor Levels to 32. Click the OK button.
- Click on the Contour plot, and then click on the Palettes button on the pop-up Mini Toolbars. Then select the Rainbow palette from the drop-down.
- Click twice on a contour line (two separate single clicks) to select all lines at that level. Change the color to Green by using the Line/Border Color button in the Font toolbar. Change the width to 3 by using the Line/Border Width button in the same toolbar.
- Make sure only one contour line is selected (not all the contour lines at that level) and right click on the selected contour line. Select Add Contour Label to add a label.
- Click twice on a contour line to select it, right click and select Extract Contour Lines. Origin will extract the data for that contour line to a worksheet. The following image shows part of the data in the worksheet:
Create a Contour Plot from XYZ Data
Origin can create contour plots directly from XYZ data in a worksheet without the need for an intermediate matrix. Delaunay Triangulation is used to compute and draw the contour lines.
- Start with an empty worksheet. Select Help: Open Folder: Sample Folder... to open the "Samples" folder. In this folder, open the Matrix Conversion and Gridding subfolder and find the file 3D XYZ.dat. Drag-and-drop this file into the empty worksheet to import it.
- Highlight the third column and right click on it to select Set As: Z. SelectPlot > Contour: Contour - Color Fill to create a graph as in the following image:
Show the Triangulation Grid
- Show the triangulation grid that is used to create a contour plot from the data. The individual data points are located at the nodes or vertices of the grid.
- Start with an empty worksheet. Select Help: Open Folder: Sample Folder... to open the "Samples" folder. In this folder, open the Matrix Conversion and Gridding subfolder and find the file XYZ Random Gaussian.dat. Drag-and-drop this file into the empty worksheet to import it.
- Highlight the third column and right click on it to select Set As: Z. SelectPlot > Contour: Contour - Color Fill to create a graph.
- Double click on the contour plot to open the Plot Details dialog. On the Colormap/Contours tab, click on the Line heading to open the Contour Lines dialog. Deselect Shown on Major Levels Only and select Hide All to hide all the contour lines. Click OK to close this dialog. Then select the Show Grid Lines and Show Data Points check boxes. Click OK to close the Plot Details dialog.
The contour plot with its superimposed grid should look like this:
Apply Custom Boundary
A custom boundary can be applied to contour plots created directly from XYZ data where user provides the data points for the boundary in additional columns of the same worksheet. This feature is useful when there is a specific boundary data that defines the outline of an object, for example the profile of an engine where the contour shows engine temperature.
-
Continue to use the worksheet and the contour plot that was created with the XYZ Random Gaussian.dat in the previous example.
- In the XYZRandomGaus workbook, click the Add New Columns button twice to add two columns. Highlight the two columns and right click on them. Select Set As: XY XY from the context menu and enter four rows of data such as below:
- Double click on the contour plot to open the Plot Details dialog. Select the Contouring Info tab in the right panel. Set the dialog as in the following image to customize the boundary for the contour plot. Remember to uncheck the Show Grid Lines and Show Data Points check boxes in the Color Map/Contours tab. Click OK to close the Plot Details dialog.
The graph should resemble the following image:
| Prior to Origin 2018 SR0, 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.
|
|