Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/sectionproperties/analysis/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import matplotlib.axes
import matplotlib.patches as mpatches
import matplotlib.tri as tri
import numpy as np
from matplotlib.colors import ListedColormap
from rich.console import Console
Expand Down Expand Up @@ -1680,6 +1681,7 @@ def plot_warping_function(
title: str = "Warping Function",
level: int = 20,
cmap: str = "viridis",
alpha: float = 0.2,
with_lines: bool = True,
**kwargs,
):
Expand All @@ -1690,6 +1692,7 @@ def plot_warping_function(
level: Number of contour levels
cmap: Colormap
with_lines: If set to True, contour lines are displayed
alpha: Transparency of the mesh outlines: :math:`0 \leq \alpha \leq 1`
kwargs: Passed to :func:`~sectionproperties.post.post.plotting_context`

Raises:
Expand All @@ -1707,26 +1710,30 @@ def plot_warping_function(
with post.plotting_context(title=title, **kwargs) as (fig, ax):
assert ax

loc = self.mesh["vertices"]
# create triangulation
triang = tri.Triangulation(
self._mesh_nodes[:, 0],
self._mesh_nodes[:, 1],
self._mesh_elements[:, 0:3],
)

if with_lines:
ax.tricontour(
loc[:, 0],
loc[:, 1],
triang,
self.section_props.omega,
colors="k",
levels=level,
)

ax.tricontourf(
loc[:, 0],
loc[:, 1],
triang,
self.section_props.omega,
cmap=cmap,
levels=level,
)
ax.set_xlabel("X")
ax.set_ylabel("Y")

# plot the finite element mesh
self.plot_mesh(alpha=alpha, materials=False, **dict(kwargs, ax=ax))

return ax

Expand Down