📌  相关文章
📜  Python中的 plotly.express.scatter_3d()函数

📅  最后修改于: 2022-05-13 01:55:38.426000             🧑  作者: Mango

Python中的 plotly.express.scatter_3d()函数

Python的 Plotly 库对于数据可视化和简单轻松地理解数据非常有用。 Plotly 图形对象是一个易于使用的高级界面。

plotly.express.scatter_3d()函数

此函数用于创建 3D 散点图,可用于 pandas 数据帧。数据帧的每一行都由散点图中 3D 空间中的符号标记表示。

示例 1:

Python3
# Python program to demonstrate 3D scatter
# plot
  
import plotly.express as px
  
df = px.data.tips()
  
plot = px.scatter_3d(df, x = 'day', 
                     y = 'total_bill',
                     z='sex')
plot.show()


Python3
# Python program to demonstrate scatter
# plot
  
import plotly.express as px
  
df = px.data.tips()
  
plot = px.scatter_3d(df, x = 'day', 
                     y = 'total_bill',
                     z = 'sex', 
                     color = 'time')
plot.show()


Python3
# Python program to demonstrate scatter
# plot
  
import plotly.express as px
  
df = px.data.tips()
  
plot = px.scatter_3d(df, x = 'day', 
                     y = 'total_bill', 
                     z = 'sex', 
                     color = 'time',
                     symbol = 'total_bill')
plot.show()


输出:

示例 2:使用颜色参数

Python3

# Python program to demonstrate scatter
# plot
  
import plotly.express as px
  
df = px.data.tips()
  
plot = px.scatter_3d(df, x = 'day', 
                     y = 'total_bill',
                     z = 'sex', 
                     color = 'time')
plot.show()

输出:

示例 3:

Python3

# Python program to demonstrate scatter
# plot
  
import plotly.express as px
  
df = px.data.tips()
  
plot = px.scatter_3d(df, x = 'day', 
                     y = 'total_bill', 
                     z = 'sex', 
                     color = 'time',
                     symbol = 'total_bill')
plot.show()

输出: