Plot Stacked Contour Plots in a Cylinder Coordinates

This blog will explain how to create a Stacked Contour Plot if user has data with Cylindrical Coordinates(ro, theta and Z),


It will involve the following steps:

  • interpolate data and convert data from cylindrical coordinates to Cartesian coordinates
  • Use XYZ gridding to convert xyz data into matrix
  • Clip data in matrix with circle.
  • Plot stacked colormap surfaces and set them to flat.
  • Shift them on Z axis to get stacked contour plots

To follow this blog, please download the attached zip file Cylindrical Coordinates and extract the contents.

Convert from Cylindrical to Cartesian Coordinates

  1. With a new book active, choose Data: Import From File: Single ASCII and browse to the file z=0.txt. Accept the default settings in the import dialog and click OK. The data file is imported with the Long Name and Units and Comments correctly imported into the column label rows.
  2. Select the first column, then right-click and choose Set As > Y so all three worksheet columns are designated as Y columns.
  3. With the first column still selected, go to Analysis: Mathematics: Interpolate/Extrapolate: Open Dialog… Use the settings shown below and click OK.Image2
  4. Now click on the small green operations lock on the top right of the newly added Col(D) and select Repeat This for All Y Columns from the context menu. This will repeat the same interpolation operation for all your columns.
  5. Add three new columns to the sheet. Designate them as X, YZ and assign Long Names X, YZ as well.  In the Comments enter Cartesian Coordinates for all three columns.
  6. Enter the following formulas into the F(X)= cells of the 3 new columns,  respectively. This will convert XYZ values into Cartesian coordinates.
    • abs(col(D)*cos(col(E)))<0.001? 0:col(D)*cos(col(E))
    • abs(col(D)*sin(col(E)))<0.001? 0:col(D)*sin(col(E))
    • Col(F)



Convert all data files to Cartesian Coordinates

  1. With this workbook active, choose Data: Import From File: Multiple ASCII. Select the other txt files from z=20 to z=80 and click Add Files. Make sure Show Options Dialog is checked then click OK.
  2. In the impASCII dialog that opens, under Import Options, set both 1st File Import Mode 、 Multi-File (except 1st) Import Mode to Start New Books . Set Template Name to <clone>, which will create new books as needed, putting each new data file into a new book and cloning all operations of the current book. Click OK to close the dialog and clone your input.
  3. Choose Window: Tile Horizontally, to see that you have one workbook for every z-value dataset:clone_import_result

At this point, If you were to highlight any Z column and choose Plot: 3D : 3D Colormap Surface, then open the Plot Details dialog, check the Flat checkbox on Surface tab, you will see the plot is approximately but not perfectly round. Our goal is to plot each dataset as cross-sections in  a perfect cylinder, so we need to perform some additional steps.

Convert XYZ Data to Matrix

    1. Select the Z column  (the last column) in the z=0 worksheet and choose Worksheet: Convert to Matrix: XYZ Gridding.
    2. Expand Gridding Settings and set the Gridding Method and Parameters as Random (Thin Plate Spline).
    3. Uncheck the box next to ColumnsRows controls and set both as 450.
    4. Click OK, and this will generate a new matrix.
    5. With the matrix active, choose View: Show Image Thumbnails. Right-click 1st image icon and use Add to add four more matrix objects to the matrix sheet. These will hold the other XYZ gridding datasets.
    6. Now select the Z column from z=20 worksheet, press the SHIFT key and  and choose Worksheet: Convert to Matrix: XYZ Gridding: <last used>.xyz_gridding_shift
    7. This will open the XYZ Gridding dialog with previous settings loaded. Click the arrow button > to far right of Output Matrix and select Matrix Browser. Set List Matrices to Current Project, then select the second matrix object (Index = 2) in the list. Click Add and then OK out of the dialog.matrix_browser
    8. Click OK to do the XYZ gridding for the second z=20 dataset. Repeat the above steps for z=40 z=60 and z=80. In the end you should have a matrix book with all the five datasets converted to matrices. You can double click on the text under the thumbnails to edit them and put in the dataset names.

Cut off Data outside the Circle

  1. As you can see from matrix data and corresponding thumbnails, the matrix has a square shape, not circular. We want to trim the dataset leave just leave data within a circle. To do this, Add 6 more objects to the matrix.
  2. Click on the sixth thumbnail and press Ctrl+Q  to open the Set Values dialog box.
  3. Put the following equation into the dialog (here, 33000 is the radius): (X^2+Y^2)>33000?0/0:0. This will generate a matrix with a circular shape. All values within circle are 0. All values outside the circle are missing values.
  4. For 7th matrix, use Ctrl+Q to open the dialog and put in the equation : Mat(1)+Mat(6). This will trim the 1st matrix values so all values outside the circle will be missing values.
  5. For the remaining matrix objects, use these respective equations to trim:
    8> Mat(2)+Mat(6)
    9> Mat(3)+Mat(6)
    10> Mat(4)+Mat(6)
    11> Mat(5)+Mat(6)
    Matrix objects from 7 to 11 are those with perfect circle shapes. You can rename these as well. Your matrix should now look like this:Image13


Plot Stacked Contour Plots

  1. With the 7th matrix active, choose Plot: 3D: 3D Colormap Surface. A 3D plot will be created.
  2. Double click on the Layer Icon to open the Layer Contents dialog. Now move only the clipped matrices from left to right side of the dialog box..Image14
  3. This will add all the matrices to one graph and it will look very messy:
  4. Double click on the plots to open the Plot Details dialog and on the Surface tab, check the Flat checkbox. Check the Shift in Z... checkbox and for each plot set their respective offsets of 0, 20, 40, 60, 80.
  5. For each plot, you should also disable Mesh on the Mesh tab and disable Contour lines on the Colormap/Contour tab.Image17
  6. Once you have done this for all the plots, in the Axis dialog you can set the Z scale from 0-100 and add thick black Gridlines on the Z axis.

The end product will now look like this:



メールアドレスが公開されることはありません。 * が付いている欄は必須項目です