New To dash. Is there a way to create this for a dash board

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()
</>

1 Like

hi @Eaglefang79
Welcome to the Dash community.

First, can you please put your code in preformatted text </>
Second, are you getting a specific error, or are you just asking how to get your matplotlib graph into Dash?

No I am just trying to build what I did in matplotlib, so I can use it for the web.

Well, from my experience, combining matplotlib into Dash is not intuitive. Dash works best with Plotly graphs.

However, one way to do it is to convert your graphs to html figures with mpld3 and put them inside an Iframe. I talk about that in this tutorial:

1 Like

Is it possible to build what I did in Dash with the splatter plots in the 3-d image? I am trying to build a cylinder shape where the splatter plots represent tempatures like I did with matplotlib.

Thanks