📜  Python中的 plotly.express.scatter_ternary()函数

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

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

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

plotly.express.scatter_ternary()函数

此方法用于创建三元图。三元图用于描述等边三角形上三个变量的比率。

示例 1:

Python3
import plotly.express as px
  
df = px.data.iris()
  
plot = px.scatter_ternary(df, a = 'sepal_width',
                          b = 'sepal_length', 
                          c = 'petal_width')
plot.show()


Python3
import plotly.express as px
  
df = px.data.iris()
  
plot = px.scatter_ternary(df, a = 'sepal_width', 
                          b = 'sepal_length',
                          c='petal_width',
                          color = 'species',
                          size = 'petal_length')
plot.show()


Python3
import plotly.express as px
  
df = px.data.iris()
  
plot = px.scatter_ternary(df, a = 'sepal_width',
                          b = 'sepal_length', 
                          c = 'petal_width', 
                          color = 'species',
                          size = 'petal_length',
                          symbol = 'species_id')
plot.show()


输出:

示例 2:使用大小和颜色参数

Python3

import plotly.express as px
  
df = px.data.iris()
  
plot = px.scatter_ternary(df, a = 'sepal_width', 
                          b = 'sepal_length',
                          c='petal_width',
                          color = 'species',
                          size = 'petal_length')
plot.show()

输出:

示例 3:使用符号参数

Python3

import plotly.express as px
  
df = px.data.iris()
  
plot = px.scatter_ternary(df, a = 'sepal_width',
                          b = 'sepal_length', 
                          c = 'petal_width', 
                          color = 'species',
                          size = 'petal_length',
                          symbol = 'species_id')
plot.show()

输出: