1

I have been using plotly for dataframe visualisation, but when the data type is array, what is the best way to create an interactive plot, apart from converting array into dataframe?

Code I previously used for dataframe:

import plotly.express as px

fig = px.scatter_3d(df, x='col1', y='col2', z='col3',)

fig.update_traces(marker=dict(size=2,
                         line=dict(width=0.01)
                             )
                 )

fig.update_layout(showlegend=True, 
                  width=900, 
                  height=900,
                  title = 'My Plot')
fig.show()

1 Answer 1

1

If you mean that you have a numpy array whose columns (or rows) give the coordinates of points you want to plot, then you can assign these columns to the x, y and z arguments:

import plotly.express as px
import numpy as np

X = np.random.randint(0, 10, (10, 3))
fig = px.scatter_3d(x=X[:,0], y=X[:, 1], z=X[:, 2])
fig.show() 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.