Skip to content

Commit

Permalink
Add documentation for 3D scatter plot & surface plot (#192)
Browse files Browse the repository at this point in the history
Co-authored-by: JennaPaikowsky <[email protected]>
  • Loading branch information
phchen95 and JennaPaikowsky authored Nov 26, 2024
1 parent d3c26cb commit d415360
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
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

0 comments on commit d415360

Please sign in to comment.