.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plotting/plot_misc_surfaces.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plotting_plot_misc_surfaces.py: .. _plot_misc_surfaces_gallery: Miscellaneous Surfaces ================================ This gallery contains fun miscellaneous plots. .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: Python import oat_python as oat import numpy as np import plotly.graph_objects as go import itertools .. GENERATED FROM PYTHON SOURCE LINES 17-19 Orthographic projection (dropping perspective effect) -------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 21-59 .. code-block:: Python trace_octahedron = oat.plot.surface_octahedron() trace_octahedron.update(opacity=0.1) points = np.array( # coordinate oracle [ # first four columns "walk around the equator along adjacent vertices" # the final two columns represent the north/south poles [ -1, 0, 1, 0, 0, 0 ], # x [ 0, -1, 0, 1, 0, 0 ], # y [ 0, 0, 0, 0, -1, 1 ], # z ] ).T circle = [ [0,1], [1,2], [2,3], [3,0] ] triangles = np.array( [ edge + [pole] for edge in circle for pole in [4,5] ] ) edges = oat.simplex.dimension_m_faces_for_simplices( triangles, m=1 ) trace = oat.plot.trace_3d_for_edges( edges=edges, points=points ) trace.update(mode="lines+markers", line=dict(color="white", width=4), marker=dict(color="cornflowerblue", size=15), ) fig = go.Figure( [trace_octahedron, trace]) fig.update_layout( template="simple_white", height=700, scene = dict( aspectratio=go.layout.scene.Aspectratio(x=1, y=1, z=1.5), # controls zoom xaxis = dict(range=[-1.2, 1.2],), # x axis limits yaxis = dict(range=[-1.2, 1.2],), # y axis limits zaxis = dict(range=[-1.2, 1.2],), # z axis limits camera=dict( projection=dict( type='orthographic' ) ) ), ) fig .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 60-62 A wire sphere -------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 64-78 .. code-block:: Python data = oat.plot.wire_sphere_3d(0,0,0,1, nlattitude=5, nlongitude=4) for n, trace in enumerate(data): trace.update( legendgroup="1", showlegend = (n==0), line=dict(color="white", width=3) ) fig = go.Figure(data=data) fig.update_layout( title=dict(text="Wireframe sphere"), height=700, template="plotly_dark",) fig.update_layout(scene = dict(xaxis = dict(showgrid = False,showticklabels = False, ), yaxis = dict(showgrid = False,showticklabels = False), zaxis = dict(showgrid = False,showticklabels = False) )) fig .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 79-81 Simplices -------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 83-93 .. code-block:: Python ppoints = np.random.rand(10,3) simplices = [list(x) for x in itertools.combinations( range(5),4)] triangles = oat.simplex.dimension_m_faces_for_simplices( simplices, m=2 ) trace = oat.plot.trace_3d_for_triangles( triangles, points=ppoints ) trace.update(intensity=np.random.rand(10)) data = [trace] fig = go.Figure(data) fig .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 94-96 Rectangle -------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 98-116 .. code-block:: Python trace, x, y, z = oat.plot.surface_rectangle( -1,1, -2,2, -4, 4 ) trace.update( surfacecolor = x * y * z ) fig = go.Figure( data=[trace] ) fig.update_layout( height=800 ) fig.update_layout( title = f"Rectangle", scene = dict( # aspectmode = "cube", aspectratio=go.layout.scene.Aspectratio(x=2, y=2, z=2), xaxis = dict(range=[-5, 5],), yaxis = dict(range=[-5, 5],), zaxis = dict(range=[-5, 5],), ) ) fig .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 117-119 Cubes -------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 121-122 PLOT THE POINT CLOUD .. GENERATED FROM PYTHON SOURCE LINES 122-152 .. code-block:: Python data = [] trace = go.Scatter3d(x=points[:,0],y=points[:,1],z=points[:,2], mode="markers", marker=dict(symbol="circle-open", color=points[:,0], colorscale="rainbow"), name="Point cloud") data.append(trace) # PLOT THE HYPEREDGES for counter, point in enumerate(points): trace, x, y, z = oat.plot.surface_cube( point[0],point[1],point[2], width=1, anchor="center") trace.update(opacity=1, showscale=False, showlegend=True, name=f"Edge {counter}" ) trace.update(surfacecolor = x, cmin=-2, cmax=2, colorscale="greys") # hide some cubes (but you can toggle them back on) if counter %2 ==0 : trace.update(visible='legendonly',) data.append(trace) fig = go.Figure(data) fig.update_layout( height=800 ) fig.update_layout( title = f"Toggle the cubes", scene = dict( # aspectmode = "cube", aspectratio=go.layout.scene.Aspectratio(x=2, y=2, z=2), xaxis = dict(range=[-2.5,2.5],), yaxis = dict(range=[-2.5,2.5],), zaxis = dict(range=[-2.5,2.5],), ) ) fig .. raw:: html


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.126 seconds) .. _sphx_glr_download_auto_examples_plotting_plot_misc_surfaces.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_misc_surfaces.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_misc_surfaces.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_misc_surfaces.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_