Plot Stacked Contour Plots in a Cylinder Coordinates

posted in: Graphing | 0

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

Image18

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 attach zip fileCylindrical Coordinates.

Convert from Cylindrical to Cartesian Coordinates

  1. Start a new sheet. Go to File: Import: Single ASCII and browse to the dataset z=0.txt. Accept the default settings in the import dialog and click OK. This will import the Long name and units and comments correctly.
  2. Set the first column as Y so all three columns are Y Image1
  3. Now select the first column, and go to Analysis: Mathematics: Interpolate/Extrapolate: Open Dialog… Use the settings shown below 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 do the same interpolation for all your columns. Image3 Image4
  5. Add three new columns to the sheet. Designate them as X, Y and Z and call the long names X, Y and Z as well. Set the Comments for all three as Cartesian Coordinates.
  6. In F(X)= cell of the 3 new columns, enter the following formula to convert to 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 Book1 active, choose File: Import: Multiple ASCII… Select other txt files from z=20 to z=80.
  2. In the impASCII dialog that opens next, set Import Mode: Start New Books. Template Name: <clone>, which will clone the current Book1 to create new books and put each new data into the new book with updated conversion result.clone_import
  • If you go to Window: Tile Horizontally, you will see you have one workbook for every z value data:

clone_import_result

 

If now you highlight any Z column and choose Plot: 3D Surface: Colormap Surface. Then double click the plot to open Plot Details dialog. Check Flat checkbox on Surface tab. U will see the plot is pretty round but not perfectly. If you want to plot them perfectly in cylinder. We need to do the following steps.

Convert XYZ Data to Matrix

  1. Select Z column in z=0 worksheet and choose Worksheet: Convert to Matrix: XYZ Gridding: Open Dialog menu.
  2. Set the Gridding Method and Parameters as Random (Thin Plate Spline).
  3. Uncheck the checkbox next to Columns and Rows control and set both as 450.xyz_gridding_db
  4. Click OK, and this will generate a new matrix. Go to View: Show Image Thumbnail. Right click 1st image icon to add 4 more matrix objects to hold other XYZ gridding results.xyz_gridding_add
  5. Now select the Z column from z=20 worksheet, press SHIFT key and  and choose Worksheet: Convert to Matrix: XYZ Gridding: <last used>.xyz_gridding_shift
  6. This will open the XYZ Gridding dialog with previous settings loaded. Click > button next to Output Matrix and select Matrix Browser
  7. In the Matrix Browser select the second sheet in the matrix we just created. matrix_browser
  8. Click Add and then OK out of the dialog. Click OK to do the XYZ gridding.
  9. 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.Image12

Cut off Data outside the Circle

  1. As you can see from matrix data and corresponding thumbnails, it’s a square instead of a circle. We want to clip around to just leave data within a circle. To do this, Add 6 more objects in the matrix.
  2. Click on the sixth thumbnail and pres Ctrl+Q and 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 circle shape. All values within circle is 0. All values outside the circle is missing values.
  3. For 7th matrix, use Ctrl+Q to open the dialog and put in the equation : Mat(1)+Mat(6), this will trim 1st matrix values so all values outside the circle will be missing values. 
  4. For the consecutive matrices use the equation Mat(2)+Mat(6) Mat(3)+Mat(6) Mat(4)+Mat(6)  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 Surface: Color Map Surface.
  2. A 3D plot will be created. Double click on the Layer Icon to open the Layer Contents dialog. Now move all the clipped matrices from left to right.Image14
  3. This will add all the matrices to one graph and it will look very messy:Image15
  4. Double click on the plots to open the Plot Details dialog and on the Surface option check Flat checkbox and also check Shift in Z… checkbox. For each plot set an offset 0, 20, 40, 60, 80 respectively. You can also disable Mesh on the Mesh tab and disable Contour lines on the Colormap/Contour tab.Image16 Image17
  5. 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:

Image18

Leave a Reply