In [1]:
#general imports
import pygslib
import plotly.offline as plotly
import plotly.graph_objs as go
plotly.offline.init_notebook_mode()
#make the plots inline
%matplotlib inline
In [2]:
#get the data in gslib format into a pandas Dataframe
mydata= pygslib.gslib.read_gslib_file('../datasets/cluster.dat')
In [3]:
trace1 = go.Scatter3d(
x=mydata['Xlocation'],
y=mydata['Ylocation'],
z=mydata['Primary'],
mode='markers',
marker=dict(
size=5,
color=mydata['Primary'], # set color to an array/list of desired values
colorscale='Viridis', # choose a colorscale
opacity=0.8
)
)
data = [trace1]
layout = go.Layout(
margin=dict(
l=0,
r=0,
b=0,
t=0
)
)
fig = go.Figure(data=data, layout=layout)
plotly.iplot(fig, filename='3d-scatter-colorscale')
In [ ]: