Customizing 3D Scatter Plot
In Plotly, through the parameters of px.scatter_3d, it is possible to customize the style of the figure for some option.
Example 1: Using the Iris dataset.
Python3
import plotly.express as px df = px.data.iris() fig = px.scatter_3d(df, x = 'sepal_width' , y = 'sepal_length' , z = 'petal_width' , color = 'species' , size = 'petal_length' , size_max = 20 , opacity = 0.5 ) fig.show() |
Output:
Example 2: Using tips dataset
Python3
import plotly.express as px df = px.data.tips() fig = px.scatter_3d(df, x = 'total_bill' , y = 'day' , z = 'time' , color = 'sex' , size = 'tip' , size_max = 20 , opacity = 0.7 ) fig.show() |
Output:
3D scatter plot using Plotly in Python
Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library.