Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
DataScienceUWL
GitHub Repository: DataScienceUWL/DS775
Path: blob/main/Lessons/Lesson 07 - Global Optimization 2/scripts/sphere2d.py
871 views
1
import plotly.graph_objs as go
2
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
3
import numpy as np
4
5
x = np.linspace(-100, 100, 401)
6
y = np.linspace(-100, 100, 401)
7
X, Y = np.meshgrid(x, y)
8
Z = (X**2) + (Y**2) + 20
9
10
data = [
11
go.Surface( x = X, y = Y, z = Z, colorscale = 'Jet',
12
contours=go.surface.Contours(
13
z=go.surface.contours.Z(
14
show=True,
15
usecolormap=True,
16
highlightcolor="#42f462",
17
project=dict(z=True)
18
)
19
)
20
)
21
]
22
23
layout = go.Layout(title='Sphere',width=600,height=600)
24
fig = go.Figure(data=data, layout=layout)
25
iplot(fig)
26