我有以下数据框:
我想绘制主成分的 3D 散点图。类似的东西:
我一直在纠结剧情属性的版本。我想知道:
代码:
import pandas as pd
import string
import plotly.graph_objects as go
df = pd.DataFrame(
{
"pc1": range(11),
"pc2": range(10, -1, -1),
'pc3': range(35,46),
"Muestra": list(string.ascii_uppercase[:11]),
"color": ["#cf0c0c"] * 6 + ["#0dab51"] * 5,
},
index=range(1, 12))
data = go.Scatter3d(x=df.pc1,
y=df.pc2,
z=df.pc3,
mode='markers',
marker=dict(size=10, color=df.color, opacity=0.8))
fig = go.Figure(data=[data])
# tight layout
fig.update_layout(margin=dict(l=0, r=0, b=0, t=0))
fig.show()