Skip to content

Commit 4f31dae

Browse files
fix: doc issues
1 parent 622cd30 commit 4f31dae

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Basic Plotly usage examples
2+
===========================
3+
4+
These examples show how to use the general plotter with Plotly backend included in the Visualization Interface Tool.

examples/01-basic-plotly-examples/plain-usage.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,24 @@
1919
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
22+
"""
23+
.. _ref_plain_usage_plotly:
24+
25+
=================================
26+
Plain usage of the plotly backend
27+
=================================
28+
29+
This example shows the plain usage of the Plotly backend in the Visualization Interface Tool to plot different objects,
30+
including PyVista meshes, custom objects, and Plotly-specific objects.
31+
"""
2232

2333
from ansys.tools.visualization_interface.backends.plotly.plotly_interface import PlotlyBackend
2434
from ansys.tools.visualization_interface.types import MeshObjectPlot
2535
from ansys.tools.visualization_interface import Plotter
2636
import pyvista as pv
2737
from plotly.graph_objects import Mesh3d
2838

39+
2940
# Create a plotter with the Plotly backend
3041
pl = Plotter(backend=PlotlyBackend())
3142

@@ -35,8 +46,12 @@
3546
# Plot the mesh
3647
pl.plot(mesh)
3748

49+
#####################
3850
# Display the plotter
39-
pl.show()
51+
#
52+
# code-block:: python
53+
#
54+
# pl.show()
4055

4156
# Now create a custom object
4257
class CustomObject:
@@ -62,8 +77,14 @@ def name(self):
6277
# Plot the custom mesh object
6378
pl.plot(mesh_object_cube)
6479

65-
# Since Plotly is a web-based visualization, we can show the plot again to include the new object
66-
pl.show()
80+
###########################
81+
# Display the plotter again
82+
# =========================
83+
# Since Plotly is a web-based visualization, we can show the plot again to include the new object.
84+
#
85+
# code-block:: python
86+
#
87+
# pl.show()
6788

6889
# Add a Plotly Mesh3d object directly
6990
custom_mesh3d = Mesh3d(
@@ -77,7 +98,6 @@ def name(self):
7798
opacity=0.50
7899
)
79100
pl.plot(custom_mesh3d)
80-
pl.show()
81101

82102
# Show other plotly objects like Scatter3d
83103
from plotly.graph_objects import Scatter3d
@@ -90,4 +110,11 @@ def name(self):
90110
marker=dict(size=5, color='red')
91111
)
92112
pl.plot(scatter)
93-
pl.show()
113+
114+
###########################
115+
# Display the plotter again
116+
# =========================
117+
#
118+
# code-block:: python
119+
#
120+
# pl.show()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (C) 2024 - 2025 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
"""Plotly initialization."""

0 commit comments

Comments
 (0)