{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n\n# Advanced Plotting\nHarness some of the plotting features provided by :func:`~sectionproperties.post.post.plotting_context`.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# sphinx_gallery_thumbnail_number = 1\n\nimport sectionproperties.pre.library.steel_sections as steel_sections\nfrom sectionproperties.analysis.section import Section\nimport matplotlib.pyplot as plt"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "The below example creates a 100x6 SHS and plots the geometry, mesh, centroids and torsion vectors\nin a 2x2 subplot arrangement.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "geometry = steel_sections.rectangular_hollow_section(d=100, b=100, t=6, r_out=15, n_r=8)\n\n# Plot the geometry\nax = geometry.plot_geometry(nrows=2, ncols=2, figsize=(12, 7), render=False, labels=[])\nfig = ax.get_figure()  # get the figure\n\n# Create a mesh and section object, for the mesh, use a maximum area of 2\ngeometry.create_mesh(mesh_sizes=[2])\nsection = Section(geometry)\nsection.plot_mesh(ax=fig.axes[1], materials=False)  # plot the mesh\n\n# Perform a geometry and warping analysis\nsection.calculate_geometric_properties()\nsection.calculate_warping_properties()\nsection.plot_centroids(ax=fig.axes[2])  # plot the cetnroids\n\n# Perform a stress analysis with Mzz = 10 kN.m\nstress = section.calculate_stress(Mzz=10e6)\nstress.plot_vector_mzz_zxy(\n    ax=fig.axes[3], title=\"Torsion Vectors\"\n)  # plot the torsion vectors\nplt.show()  # show the plot"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.9.15"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}