CARVIEW |
Select Language
HTTP/2 200
accept-ranges: bytes
access-control-allow-origin: *
age: 0
cache-control: max-age=600
content-encoding: gzip
content-type: text/html; charset=utf-8
date: Mon, 28 Jul 2025 03:55:37 GMT
etag: W/"687e6266-d686"
expires: Mon, 28 Jul 2025 04:05:37 GMT
last-modified: Mon, 21 Jul 2025 15:53:10 GMT
server: Vercel
strict-transport-security: max-age=63072000
vary: Accept-Encoding
via: 1.1 varnish
x-cache: MISS
x-cache-hits: 0
x-fastly-request-id: 52f929f1dc8301f46258b83eb3479b80e610f43c
x-github-request-id: BAC3:3EDB09:19B6C1:1EE536:6886F4B9
x-proxy-cache: MISS
x-robots-tag: index
x-served-by: cache-bom-vanm7210054-BOM
x-timer: S1753674937.494342,VS0,VE217
x-vercel-cache: MISS
x-vercel-id: bom1::j8vsj-1753674937462-132797e7a012
content-length: 12274
3d subplots in Python
3D Subplots in Python
3D Subplots in Plotly
Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Sign up for early access now.
3D Surface Subplots¶
In [1]:
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import numpy as np
# Initialize figure with 4 3D subplots
fig = make_subplots(
rows=2, cols=2,
specs=[[{'type': 'surface'}, {'type': 'surface'}],
[{'type': 'surface'}, {'type': 'surface'}]])
# Generate data
x = np.linspace(-5, 80, 10)
y = np.linspace(-5, 60, 10)
xGrid, yGrid = np.meshgrid(y, x)
z = xGrid ** 3 + yGrid ** 3
# adding surfaces to subplots.
fig.add_trace(
go.Surface(x=x, y=y, z=z, colorscale='Viridis', showscale=False),
row=1, col=1)
fig.add_trace(
go.Surface(x=x, y=y, z=z, colorscale='RdBu', showscale=False),
row=1, col=2)
fig.add_trace(
go.Surface(x=x, y=y, z=z, colorscale='YlOrRd', showscale=False),
row=2, col=1)
fig.add_trace(
go.Surface(x=x, y=y, z=z, colorscale='YlGnBu', showscale=False),
row=2, col=2)
fig.update_layout(
title_text='3D subplots with different colorscales',
height=800,
width=800
)
fig.show()
Reference¶
See https://plotly.com/python/subplots/ for more information regarding subplots!
What About Dash?¶
Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.
Learn about how to install Dash at https://dash.plot.ly/installation.
Everywhere in this page that you see fig.show()
, you can display the same figure in a Dash application by passing it to the figure
argument of the Graph
component from the built-in dash_core_components
package like this:
import plotly.graph_objects as go # or plotly.express as px
fig = go.Figure() # or any Plotly Express function e.g. px.bar(...)
# fig.add_trace( ... )
# fig.update_layout( ... )
from dash import Dash, dcc, html
app = Dash()
app.layout = html.Div([
dcc.Graph(figure=fig)
])
app.run(debug=True, use_reloader=False) # Turn off reloader if inside Jupyter
