【发布时间】:2021-09-13 06:27:52
【问题描述】:
我使用 UMAP 可视化数据,但无法添加适当的注释。如何使用相同长度的另一个数据框将悬停文本添加到绘图表达散点图?
据我了解,我只能从data_2d 那里指定一列。我可以从another_df 获取所有行作为注释吗?
import plotly.express as px
def scatter(data_2d, labels, another_df):
c = dict(zip(labels.unique, px.colors.qualitative.G10)) # make the same colors for another data
fig = px.scatter(
data_2d, x=0, y=1,
color=labels,
color_discrete_map=c,
text=another_df, # here I'm stuck
# expected annotation
# column1: 57575874
# column2: 0.4545
# columnN: ....
# hover_data awaits for labels from data_2d and it doesn't work
# text is constant, I see just a mess of text
)
fig.update_traces(marker=dict(size=5, opacity=0.7))
fig.show()
【问题讨论】:
-
仅从您目前的解释来看,我不太理解。我需要展示我目前正在获取的图表以及我想要添加的数据。
标签: python pandas plotly scatter-plot plotly-express