Chapter 8. Plotting with Plotly – Using Templates

As we saw in Chapter 7, manually populating information into the Plot Manager dialog becomes increasingly time-consuming as you add more canvases and traces.  For instance, suppose you want to see data for all combinations of parameters and responses for the centered parameter study of the cantilever beam (which we ran in Chapter 6).  Suppose also that you want one canvas per response, and a trace for each parameter on each canvas.  This would be a total of 21 traces, which would take a long time to manually input, not to mention the fact that doing so is error-prone, requiring lots of trial and error to get the plot exactly the way you want it.

To alleviate this, we have provided the concept of “plotting templates,” which are pre-baked configurations for the Plot Manager dialog.  To access all available plotting templates:

  • From the Plot Manager dialog, click on the “Choose a plotting template” button in the top-left corner.
  • Alternately, you can right-click on a Dakota input file and select New > Plot template from this file.

DakotaGuiManual_68_Chapter8_1.png

Template:  Centered Parameter Study Response Comparison

Note:  This example assumes you have collected data from the cantilever beam example in Chapter 6.

Let's return to the scenario we described above.  We would like a template that creates one canvas per response, and includes a trace for each parameter on each canvas, to show us how varying a parameter affected that response.

There just so happens to be a template for this!  Select "Centered Parameter Study Response Comparison" from the dropdown in the Plotting Templates dialog.

DakotaGuiManual_68_Chapter8_2.png

You will need to provide plot data using the Plot Data button (see Chapter 7 for information on how to do this), as well as an orientation for your canvases (horizontal or vertical), but everything else is populated for you.  (You can also choose to filter parameters and responses, but this is not required)

Hit OK with these options selected and you’ll be taken back to the Plot Manager dialog with everything populated for you:

DakotaGuiManual_68_Chapter8_3.png

Hit the Plot button and you’ll get the response comparison view of the cantilever centered parameter study that we just ran (you’ll most likely need to expand your Plot View and refresh to see everything):

DakotaGuiManual_68_Chapter8_9.png

Generating this plot template provides the user with a lot of useful data from a minimal amount of work.  From this plot window, we can observe trends such as:

  • Mass increases linearly with width and thickness.
  • Stress decreases exponentially when width and thickness increase linearly.
  • Displacement decreases exponentially when width and thickness increase linearly; however, displacement increases linearly when length increases linearly.

A couple of things to note:

  • For each trace, a random color and shape is automatically selected for you, but as you might expect, you can go back into the Plot Manager dialog, drill down to an individual trace, and change the color and point shape if you wish.
  • Plotly provides quick comparison data about surrounding points in a trace by hovering the mouse over points on a trace.

Below are a series of template tutorials to help you get acquainted with some of the other templates that the Dakota GUI provides.

Template:  Iteration History

"Iteration History" is a template for viewing how both parameters and responses were explored by Dakota over time.  This is useful for optimization studies, as it shows Dakota "honing in" on the optimal answer.

For this example, we will need to generate Dakota run result data that came from an optimization study.

  • Using the Search dialog (New > File from Dakota examples repository), search for "cantilever_opt_npsol.in" and import it into an existing project.
  • You will need to make some modifications to the Dakota input file.
    • Add an environment block to this study so we can record output files:
      environment
          tabular_data
              tabular_data_file 'tabular_output_file.dat'
          output_file 'dakota.out'
          error_file 'dakota.err'
          write_restart 'dakota.rst'
    • Beneath the method keyword, replace “npsol_sqp” with “optpp_q_newton”.
    • In the interface block, replace “fork” with “direct.”
    • Remove the “asynchronous evaluation_concurrency = 2” line
  • Right-click on the Dakota input file and select “Run As > Dakota.”
    • There is no specific run configuration information we need to provide (see Chapter 5 for more information on this topic).
  • Navigate to the new run results subfolder that was just generated. Verify that there is tabular output.
  • Right-click this tabular data and select "New > Plot template from this file.”
  • In the Plotting Templates dialog, select "Iteration History" from the dropdown.
  • Click the "Get Data" button and choose the run result data that was just generated.
    • In "Link to original Dakota input file" select your original Dakota input file.
    • In the tree view, select your tabular data file if it's not already selected, then select its child field that actually has the tabular data (should be called "Tabular Data Set 1" or something similar).
  • Click OK.
  • In the "Choose an orientation" dropdown, select "Horizontal." Leave other template settings as-is.
  • Click OK.
  • Verify that the Plot Window Manager dialog opens. Also verify that there are three canvases – "function eval ID/w", "function eval ID/t", and "function eval ID/obj_fn" with two overlaid canvases representing the other two responses.
  • Click "Plot."
  • Verify that the plot generates as follows (individual trace colors and the plot's title will vary):

DakotaGuiManual_68_Chapter8_5.png

Template:  Scatter Plot Matrix

​For this example, we will re-use the centered parameter study tabular output file from our cantilever beam example problem (generated in Chapter 6, also used in the Centered Parameter Study Response Comparison example above).

  • If you don't already have tabular data for this study, right-click on "dakota_cantilever_center.in" and select “Run As > Dakota.”
  • Navigate to the new run results subfolder that was just generated. Verify that there is tabular output.
  • Right-click this tabular data and select "New > Plot template from this file.”
  • Select "Scatter Plot Matrix" from the dropdown.
  • Click the "Get Data" button and choose the run result data that was just generated.
    • In "Link to original Dakota input file" select your original Dakota input file.
    • In the tree view, select your tabular data file if it's not already selected, then select its child field that actually has the tabular data (should be called "Tabular Data Set 1" or something similar).
  • In the "Choose a type of scatter plot" dropdown, select "Subset A to Subset B."
  • In the "X Axis" dropdown, select "All variables."
  • In the "Y Axis" dropdown, select "All responses."
  • Check "Draw Linear Regression" and "Text on Outer Axes Only."
  • Click OK.  Verify that there is a grid of canvases 7 long and 3 tall.
  • Click Plot.  The plot should generate as follows (individual trace colors, dot shapes, and the plot's title will vary):

DakotaGuiManual_68_Chapter8_10.png

Note that this plot template provides us with similar introspection as the Centered Parameter Study Response Comparison template - we can easily see which parameters most greatly impact the responses.  (The vertical rows of points in the center of each canvas represent places where that parameter did not vary but other parameters were varying.  You can remove these by using the "Trim No Change" option on the Plot Trace Creator dialog)

Template:  Correlation Coefficient Table

For this example, we will need to generate Dakota run result data that contains correlation matrices in its output stream.

  • Using the Dakota Examples Search dialog (New > File from Dakota examples repository), search for "cantilever_uq_sop_rel.in" and import it into your existing cantilever project.
  • Add an environment block to this study so we can record output files:
    environment
        tabular_data
            tabular_data_file 'tabular_output_file.dat'
        output_file 'dakota.out'
        error_file 'dakota.err'
        write_restart 'dakota.rst'
  • Note:  You may receive an error message:  “'response_functions' has an invalid number.  The value should be the sum of declared scalar and/or field responses underneath.”  Ignore it.
  • Run Dakota using “Run As > Dakota”.
    • There is no specific run configuration information we need to provide (see Chapter 5 for more information on this topic).
  • After you have run result data, right-click on the output stream file and select "New>Plot template from this file."
  • Select "Correlation Coefficients Table" from the dropdown of templates.
  • Click the "Get Data" button and choose the run result data that was just generated.
    • In "Link to original Dakota input file" select your original Dakota input file.
    • In the tree view, select your output stream file (not the tabular data file) if it's not already selected.
      • Choose the first available matrix ("Simple Correlation Matrix among all inputs and outputs") and click OK.
  • In the Plotting Templates dialog, choose "Mirror All Variables" from the "Choose an orientation" dropdown.
  • Click OK.
  • Verify that the Plot Window Manager dialog opens. Also verify that there is a single canvas with a single trace in this dialog.
  • Click Plot.

DakotaGuiManual_68_Chapter8_7.png

The correlation coefficients table template uses a trace feature called color scale that allows the user to define a range of colors associated with number thresholds.  By default, this template will use red for -1, white for 0, and green for 1.  However, you can define any color scale you want.  This is available in the Plot Trace Creator dialog for certain types of traces:

DakotaGuiManual_68_Chapter8_11.png

Template:  Bar Charts

For this example, we will need to generate Dakota run result data that contains matrices in its output stream.

  • Using the Dakota Examples Search dialog (New > File from Dakota examples repository), search for "cantilever_uq_sop_rel.in" and import it into your existing cantilever project.

  • Add an environment block to this study so we can record output files:
    environment
        tabular_data
            tabular_data_file 'tabular_output_file.dat'

        output_file 'dakota.out'
        error_file 'dakota.err'

        write_restart 'dakota.rst'

  • Note:  You may receive an error message:  “'response_functions' has an invalid number.  The value should be the sum of declared scalar and/or field responses underneath.”  Ignore it.
  • Run Dakota using “Run As > Dakota”.
    • There is no specific run configuration information we need to provide (see Chapter 5 for more information on this topic).
  • After you have run result data, right-click on the output stream file and select "New>Plot template from this file."
  • Select "Bar Chart Variable Comparison" from the dropdown.
  • Click the "Get Data" button and choose the run result data that was just generated.
    • In "Link to original Dakota input file" select your original Dakota input file.  In the tree view, select your output stream file if it's not already selected.
    • Choose the first matrix ("Simple Correlation Matrix among all inputs and outputs") and click OK.
  • Choose "Horizontal" from the "Choose canvas orientation" dropdown.
  • Choose "Vertical" from the "Choose bar orientation" dropdown.
  • Choose "Response" from the "Create canvas by" dropdown.
  • Click OK.
  • Verify that the Plot Window Manager dialog opens. Also verify that there are 3 canvases with a single trace on each.
  • Click Plot.
  • Verify that the plot generates as follows (colors will vary):

DakotaGuiManual_68_Chapter8_8.png