News

New paper!

Thursday, February 1, 2018

Plotly: 1st trial to make 3d plot in html



One way to share your interactive 3d plot with others without having a problem in setting up environment:
Make html file of the plot.
import pandas as pd
import plotly
import plotly.graph_objs as go

df = # pandas DataFrame

layout=go.Layout(
    scene=dict(
        xaxis=dict(title='X-axis'),
        yaxis=dict(title='Y-axis'),
        zaxis=dict(title='Z-axis'),),
    width=1000,
    margin=dict(r=20,b=10,l=200,t=10)
)
trace = go.Scatter3d(
    x=df.x,
    y=df.y,
    z=df.z,
    mode='markers',
    marker=dict(
        size=12,
        opacity=0.8
    )
)
data = [trace]
fig = go.Figure(data=data,layout=layout)
plotly.offline.plot(fig,filename='output')