Skip to content
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

Add documentation for 3D scatter plot & surface plot #192

Merged
merged 8 commits into from
Nov 26, 2024
Binary file added doc/source/_static/3d_scatter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/source/_static/3d_surface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions doc/source/examples_source/00-basic/02-plottype.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,38 @@
#
# .. image:: /_static/heatmap.png
#
# Visualize a 3D surface plot
# --------------------------
#
# A 3D surface plot allows you to visualize the data points in a terrain-like
# surface in a 3D space powered by the WebGL engine. It is a variation of a
# heatmap as they share the same data structure. The difference is that the
# surface plot visualizes the heatmap values as the Z axis data, allowing you
# to zoom in and out, and rotate to view the surface from different angles. Like
# heatmap, nan values are also supported, resulting in empty
# holes on the surface.

surface = adr_service.create_item()
# We can use the same data as we use to visualize heatmap
surface.item_table = np.array(
[
[0.00291, 0.01306, 0.02153, 0.01306, 0.00291],
[0.01306, 0.05854, 0.09653, 0.05854, 0.01306],
[0.02153, 0.09653, np.nan, 0.09653, 0.02153],
[0.01306, 0.05854, 0.09653, 0.05854, 0.01306],
[0.00291, 0.01306, 0.02153, 0.01306, 0.00291],
],
dtype="|S20",
)
surface.plot = "3d surface"
surface.format = "floatdot0"
surface.visualize()


###############################################################################
#
# .. image:: /_static/3d_surface.png
#
# Visualize a parallel coordinate plot
# ------------------------------------
#
Expand Down Expand Up @@ -227,6 +259,40 @@
#
# .. image:: /_static/sankey.png
#
# Visualize a 3D scatter plot
# --------------------------
#
# A 3D scatter plot allows you to visualize the data points in 3D space
# powered by the WebGL engine. You can zoom in and out, and rotate to view the
# data from different angles.

scatter_plot_3d = adr_service.create_item()
scatter_plot_3d.item_table = np.random.uniform(1.0, 50.0, size=(6, 20))
scatter_plot_3d.labels_row = ["X1", "Y1", "Z1", "X2", "Y2", "Z2"]
scatter_plot_3d.plot = "line"
# specified the 3D scatter's line style (default is markers+lines)
scatter_plot_3d.line_style = "none"
# specified the 3D scatter's symbol (default is solid circle)
# supportive: diamond, cross, x, circle, square (open & solid)
scatter_plot_3d.xaxis = ["X1", "X2"]
scatter_plot_3d.yaxis = ["Y1", "Y2"]
scatter_plot_3d.zaxis = ["Z1", "Z2"]
scatter_plot_3d.zaxis_format = "floatdot0"
scatter_plot_3d.yaxis_format = "floatdot0"
scatter_plot_3d.xaxis_format = "floatdot1"
scatter_plot_3d.xtitle = "x"
scatter_plot_3d.ytitle = "f(x)"
scatter_plot_3d.ztitle = "f(x,y)"
# opacity
scatter_plot_3d.line_marker_opacity = 0.7
# vis
scatter_plot_3d.visualize()


###############################################################################
#
# .. image:: /_static/3d_scatter.png
#
# Close the service
# -----------------
#
Expand Down
Loading