Skip to content

docs: adding plottly support to gallery examples #2346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d4a3791
Changing configuration
germa89 Sep 19, 2023
2eceac8
Using plotly in gallery example
germa89 Sep 19, 2023
d82aab0
chore: merge remote-tracking branch 'origin/main' into doc/adding-plo…
germa89 Oct 15, 2024
887ac03
chore: adding changelog file 2346.documentation.md [dependabot-skip]
pyansys-ci-bot Oct 15, 2024
dbb3516
test: using jorge's suggestion
germa89 Nov 25, 2024
0b24ec0
Merge branch 'main' into doc/adding-plotly-support-to-docs
germa89 Mar 17, 2025
37653f3
chore: adding changelog file 2346.documentation.md [dependabot-skip]
pyansys-ci-bot Mar 17, 2025
123f01b
build: install ansys-sphinx-theme from specific branch in documentati…
germa89 Mar 17, 2025
babac0d
test: temporory disable linkcode
Revathyvenugopal162 Mar 18, 2025
abbcdf3
test: plotly version
Revathyvenugopal162 Mar 18, 2025
3c5c2da
fix: revert changes
Revathyvenugopal162 Mar 18, 2025
fa45421
fix: add js in conf.py file
Revathyvenugopal162 Mar 19, 2025
edcb9bf
Merge branch 'main' into doc/adding-plotly-support-to-docs
Revathyvenugopal162 Mar 26, 2025
3b3138e
Update .github/workflows/doc-build.yml
Revathyvenugopal162 Mar 26, 2025
973c746
Update .github/workflows/doc-build.yml
Revathyvenugopal162 Mar 26, 2025
8522309
Update .github/workflows/doc-build.yml
Revathyvenugopal162 Mar 26, 2025
3acb6a9
fix: update the theme version
Revathyvenugopal162 Mar 27, 2025
3931b02
Update .github/workflows/doc-build.yml
Revathyvenugopal162 Mar 27, 2025
15243ac
Update pyproject.toml
Revathyvenugopal162 Mar 27, 2025
1bd7dfd
Update pyproject.toml
Revathyvenugopal162 Mar 27, 2025
4314e82
Update .github/workflows/doc-build.yml
Revathyvenugopal162 Mar 27, 2025
32a5a66
Merge branch 'main' into doc/adding-plotly-support-to-docs
germa89 Apr 1, 2025
f06f86c
Merge branch 'main' into doc/adding-plotly-support-to-docs
germa89 Apr 23, 2025
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
1 change: 1 addition & 0 deletions doc/changelog.d/2346.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs: adding plottly support to gallery examples
12 changes: 11 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
import ansys.tools.visualization_interface as viz_interface
from ansys_sphinx_theme import ansys_favicon, get_version_match
import numpy as np
import plotly.io as pio
from plotly.io._sg_scraper import plotly_sg_scraper
import pyvista
from sphinx.application import Sphinx
from sphinx.util import logging
from sphinx_gallery.sorting import FileNameSortKey

pio.renderers.default = "sphinx_gallery"

from ansys.mapdl import core as pymapdl
from ansys.mapdl.core import __version__

Expand Down Expand Up @@ -275,7 +279,11 @@
"backreferences_dir": None,
# Modules for which function level galleries are created. In
"doc_module": "ansys-mapdl-core",
"image_scrapers": ("pyvista", "matplotlib"),
"image_scrapers": (
"pyvista",
"matplotlib",
plotly_sg_scraper,
),
"ignore_pattern": "flycheck*",
"thumbnail_size": (350, 350),
"remove_config_comments": True,
Expand Down Expand Up @@ -343,6 +351,8 @@
"mapdl_commands/index": [],
}

html_js_files = ["https://cdn.plot.ly/plotly-3.0.1.min.js"]

# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
Expand Down
26 changes: 19 additions & 7 deletions examples/00-mapdl-examples/2d_plate_with_a_hole.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"""
# sphinx_gallery_thumbnail_number = 3

import matplotlib.pyplot as plt
import numpy as np
import plotly.graph_objects as go

from ansys.mapdl.core import launch_mapdl

Expand Down Expand Up @@ -396,12 +396,24 @@ def compute_stress_con(ratio):
# where ratio is (d/h)
k_t_anl = 3 - 3.14 * ratios + 3.667 * ratios**2 - 1.527 * ratios**3

plt.plot(ratios, k_t_anl, label=r"$K_t$ Analytical")
plt.plot(ratios, k_t_exp, label=r"$K_t$ ANSYS")
plt.legend()
plt.xlabel("Ratio of Hole Diameter to Width of Plate")
plt.ylabel("Stress Concentration")
plt.show()

# Create traces
fig = go.Figure()
fig.add_trace(
go.Scatter(x=ratios, y=k_t_anl, mode="lines", name=r"$K_t \text{ Analytical}$")
)
fig.add_trace(
go.Scatter(x=ratios, y=k_t_exp, mode="lines+markers", name=r"$K_t \text{ ANSYS}$")
)

fig.update_layout(
title="Analytical Comparison",
xaxis_title="Ratio of Hole Diameter to Width of Plate",
yaxis_title="Stress Concentration",
)

fig


###############################################################################
# Stop mapdl
Expand Down
Loading