1

I am using Spyder ide. I have plotly 5.5.0 installed on my pc. The following executes with no errors but does not show/popup the 3d interactive plot. Code:

import plotly.express as px
df = px.data.iris()
fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',
              color='species')
fig.show()

1 Answer 1

3

To be able to interact with the figure running from Spyder you will need to call show with the 'browser' renderer (this will show the figure on your default browser). The code provided with this change will look something like this:

import plotly.express as px
df = px.data.iris()
fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',
              color='species')
fig.show(renderer='browser')
Sign up to request clarification or add additional context in comments.

7 Comments

Also I found the following solution somewhere online but yours is simple and good. ` import plotly.express as px from plotly.offline import plot import plotly fig = px.scatter_3d(df, x=xlbl, y=ylbl, z=zlbl, color=wlbl,opacity=0, color_discrete_sequence = plotly.colors.sequential.Viridis) temp_name = 'Temp_plot.html' plot(fig, filename = temp_name, auto_open=False) plot(fig)`
Presently your solution renders a default color scale. How can I set it to viridis.
Not sure about that but maybe a kwarg of plotly.express.scatter_3d could be useful. Maybe the color_continuous_scale or color_discrete_sequence: plotly.com/python-api-reference/generated/…
Yes! color_continuous_scale = plotly.colors.sequential.Viridis solved the problem. I was assigning to the wrong kwarg. Thanks a lot.
Awesome, glad to help!
|

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.