PLAXIS Helper Tool 1

Plotting & exporting calculation results in PLAXIS Output: deformed mesh, displacements, strains, stresses.

⬇️ PDF

1️⃣ Purpose

This helper tool explains how to visualise and export calculation results from PLAXIS Output using Python scripting. Typical outputs include:

  • Deformed mesh
  • Displacement contours (Ux, Uy, Utot)
  • Deviatoric strain
  • Effective stresses and pore pressures
Tip

In general, export images around 1920 × 1080 for reporting (plot.export(file_name, 1920, 1080)).

2️⃣ Setting Output Folder & Filename

Define where your image files will be written. Update folderpath to your own directory.

import matplotlib.pyplot as plt
import numpy as np

filename_str = "output"
folderpath = r"C:\Users\username\Desktop\Plaxis_playground\plotting\\"  # use your own path
file_name = f"{folderpath}{filename_str}.png"

PLAXIS Output exports directly to disk. If the folder doesn’t exist, export will fail.

3️⃣ Phase Selection

Two common ways to select phases (choose what suits your workflow):

  • Method 1: Use Phases[] for looping (batch export).
  • Method 2: Use direct phase names like g_i.Phase_2 for one-off plots.

In many setups, g_i.Phase_1 and g_o.Phase_1 refer to the same phase concept (Input vs Output context).

phase1_s = g_i.Phases[1]
phase2_s = g_i.Phase_2
phase = g_o.Phase_11              # make this a general variable for example

4️⃣ Displaying vs Exporting Plots

You can display a plot interactively using g_i.view(phase) (opens a window), or export directly using plot.export(...).

Single plot example
g_o.Plots[-1].Phase = phase
plot = g_o.Plots[-1]

plot.ResultType = g_o.ResultTypes.Soil.DeformedMesh
plot.ScaleFactor = 1              # adjust if true scale is needed for deformed mesh
plot.export(file_name, 1920 , 1080)

If you don’t call view(), the export can run silently (good for batch workflows).

5️⃣ Multiple Phase Plotting (Batch Export)

For batch export, define a phase list and (optionally) a label map, then loop through phases and export multiple result plots per phase.

phases = [g_o.Phase_1, g_o.Phase_2, g_o.Phase_3, g_o.Phase_4]

# Map each phase object to its case number
phase_case_map = {
    g_o.Phase_1: "Case_1",
    g_o.Phase_2: "Case_2",
    g_o.Phase_3: "Case_3",
    g_o.Phase_4: "Case_4",
}
Batch export example
for phase in phases:
    case_label = phase_case_map.get(phase, phase.Name)
    print(f"Processing phase: {phase.Name}-{case_label}")

    g_o.Plots[-1].Phase = phase
    plot = g_o.Plots[-1]
    plot.zoom(90, -30, 150, -15) # if required zoom in

    plot.ResultType = g_o.ResultTypes.Soil.DeformedMesh
    plot.ScaleFactor = 1
    plot.ProjectDescription = f"Project A - {case_label} - Deformed Mesh"
    file_name = f"{folderpath}{filename_str}{case_label}_DeformedMesh.png"
    plot.export(file_name, 1920 , 1080)

    plot.ResultType = g_o.ResultTypes.Soil.Utot
    plot.LegendSettings.Autoscale = True
    plot.ProjectDescription = f"Project A - {case_label} - Total Displacement"
    file_name = f"{folderpath}{filename_str}{case_label}_Utot.png"
    plot.export(file_name, 1920 , 1080)

    plot.ResultType = g_o.ResultTypes.Soil.TotalDeviatoricStrain
    plot.ProjectDescription = f"Project A - {case_label} - Total Deviatoric Strain"
    file_name = f"{folderpath}{filename_str}{case_label}_TotalDeviatoricStrain.png"
    plot.export(file_name, 1920 , 1080)

print(f"All png files are saved in {folderpath}")

This pattern is ideal for creating reporting-ready figure packs without manually clicking through Output.

6️⃣ Result Types (Soil)

To discover available result types under ResultTypes.Soil, list its attributes:

soil_resulttypes = g_o.ResultTypes.Soil
print(dir(soil_resulttypes))

# Or iterate:
for name in dir(soil_resulttypes):
    if not name.startswith('_'):
        print(name)

Commonly used soil results include:

  • Soil.Ux, Soil.Uy, Soil.Uz, Soil.Utot
  • Soil.SigxxE, Soil.SigyyE, Soil.SigzzE (effective stresses)
  • Soil.DeformedMesh, Soil.TotalDeviatoricStrain

7️⃣ Inspect Plot Objects & Current Settings

When you’re not sure what a plot supports, inspect it (methods, properties, current settings).

dir(plot) # or
help(plot) # or
print(g_o.Plots[-1].echo())  # or print(plot.echo())
Get current plot settings
print(g_o.Plots[-1].echo())
print(g_o.Plots[-1].LegendSettings.echo())

8️⃣ Plot Formatting Options

Examples of useful toggles:

Rulers
g_o.Plots[-1].DrawRulers = True
Change the result type

ResultType controls what you are visualising (deformations, stresses, pore pressure, etc.).

# Example: Active pore pressure
g_o.Plots[-1].ResultType = g_o.ResultTypes.Soil.PActive
Plot visualisation mode
g_o.Plots[-1].PlotType = "ContourLines"
g_o.Plots[-1].PlotType = "PrincipalDirections"
Mesh settings
g_o.Plots[-1].MeshSettings.PhreaticLevel = True
g_o.Plots[-1].MeshSettings.Fixities = True
g_o.Plots[-1].MeshSettings.ClusterContours = False

9️⃣ Visual Commands: hide(), show(), zoom()

In complex models, selectively hiding objects can make plots much clearer. Use hide() to remove objects from view, and show() to bring them back.

hide()
g_o.Plots[-1].hide(g_o.Plates)       # hides all plates in the visualisation
g_o.Plots[-1].hide(g_o.Plate_1_1)    # only hides the specific plate in the visualisation

Use zoom() to reset or focus on a specific region/object.

zoom()
g_o.Plots[-1].zoom()          # resets the zoom to show the whole model
g_o.Plots[-1].zoom(g_o.Plate_2)  # zooms to fit Plate_2 into the plot's view

You can also zoom by coordinates (as used in the batch example) for consistent framing across phases.

🔟 Common Use Cases

  • Plot deformed mesh for the selected calculation phase
  • Export displacement contours for reporting
  • Compare deviatoric strain across multiple phases
  • Batch-generate plots without opening a GUI
Next-step idea

Wrap export routines into a function (phase list + result list) so you can call it from any tutorial/model.