【发布时间】:2020-09-04 04:51:24
【问题描述】:
我正在尝试使用离散的数字 x 值绘制散点图。问题是Plotly 将这些值解释为连续的,并且结果点的间距不均匀。在Seaborn 中,我可以通过将x 值转换为str 来解决这个问题,但这在Plotly 中不起作用。有什么解决办法吗? MWE 如下:
4489058292 0.60
4600724046 0.26
6102975308 0.19
6122589624 0.10
4467367136 1.67
6008680375 2.50
4588967207 0.21
4941295226 0.34
4866979526 0.18
4906915418 0.38
test_df = pd.read_clipboard(sep="\s+", names=["ID", "Value"], index_col=0)
fig = px.scatter(
test_df,
x=test_df.index.astype(str),
y=test_df,
)
fig.update_layout(showlegend=False)
【问题讨论】:
-
预期输出只是其中 x 值被视为分类的输出,以便点均匀分布。稍后我会添加预期的输出。
标签: python pandas plotly-express