I trying to take what I made in matplotlib and convert to Dash. Sorry I am a new to dash.
</>
from matplotlib.backend_bases import MouseButton
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection=‘3d’)
Scatter graph
N = 300
X = np.random.uniform(-1, 1, N, )
‘’’’’
x=[0.1,0.3,3,4,5]
y=[0.1,0.3,3,4,5]
z=[0.1,0.3,3,4,5]
‘’’’’
#Y = np.random.uniform(-1, 1, N)
#Z = np.random.uniform(-2, 2, N)
#ax.scatter(x, y, z,c=‘b’, marker=‘o’)
sensors = [
[0.1,0.1,0.3, 80],#sensor 1 x,y,z,temp
[0.3,0.3,0.3, 45],#sensonr 2
[0.1,0.3,.05, 20],#s3
[0.1,0.4,.05, 20],
[0.25,0.5,-.2, 12],
[0.25,0.5,-.325, 12],
[.74,.125,.87,87],
[.03,-.163,-.125,71]
]
for point in sensors:
style = “b”
if point[3] > 60:
style=“r”
if point[3] > 30 and point[3] <= 60:
style=“g”
ax.scatter(point[0], point[1], point[2],s=50,c=style, marker='o')
“”"
def on_move(event):
x,y,z=event.x,event.y,event.z
if event.x.inaxes:
ax=event.inaxes
print(‘data cords %f %f’%(event.xdata, event.ydata))
def on_click(event):
if event.button is MouseButton.LEFT:
print(‘disconnecting callback’)
plt.disconnect(binding_id)
binding_id = plt.connect(‘motion_notify_event’, on_move)
plt.connect(‘button_press_event’, on_click)
“”"
Cylinder
x = np.linspace(-2, 2, 100)
z = np.linspace(-5, 5, 100)
Xc, Zc = np.meshgrid(x, z)
Yc = np.sqrt(1 - Xc ** 2)
Draw parameters
rstride = 50
cstride = 20
ax.plot_surface(Xc, Yc, Zc, alpha=0.2, rstride=rstride, cstride=cstride)
ax.plot_surface(Xc, -Yc, Zc, alpha=0.2, rstride=rstride, cstride=cstride)
ax.set_xlabel(“X”)
ax.set_ylabel(" NORTH:Y")
ax.set_zlabel(“Z”)
plt.grid(False)
plt.axis(‘on’)
displaying the title
plt.title(label=“Dallas Center”,
fontsize=40,
color=“red”)
plt.show()
</>