相关疑难解决方法(0)

如何避免绘图散点图中的文本重叠?

我正在寻找一种解决方案来避免文本标签中的文本重叠。我用散点图创建图像。也许这里有自动化。

from pandas import util
import plotly.express as px
import plotly.graph_objects as go

df = util.testing.makeDataFrame()
df_keyfigures_all = df[['A','B']]



fig = px.scatter(df_keyfigures_all, x="A", y="B",size_max=60,
                     text=df_keyfigures_all.index)

fig.update_traces(textposition='top center')
fig.layout = go.Layout(yaxis=dict(tickformat=".0%"), xaxis=dict(tickformat=".0%"),
                       yaxis_title="A", xaxis_title="B")


fig.update_layout(showlegend=False)
plotly.io.write_image(fig, file='keyfigures.png', format='png')
Run Code Online (Sandbox Code Playgroud)

具有重叠标签的点

python scatter-plot plotly

12
推荐指数
2
解决办法
1万
查看次数

标签 统计

plotly ×1

python ×1

scatter-plot ×1