简体   繁体   English

如何更改 Plotly 3D scatter plot 中的标记线宽度?

[英]How to change the marker line width in Plotly 3D scatter plot?

I am plotting x/y/z data using Plotly with Python and whatever I do, I cannot make the marker lines thicker.我正在使用 Plotly 和 Python 绘制 x/y/z 数据,无论我做什么,我都无法使标记线变粗。 I followed the "manual" but they do it for 2D plots, which works for me, but I can't get it to work on the 3D version.我遵循“手册”,但他们为 2D 绘图执行此操作,这对我有用,但我无法让它在 3D 版本上工作。

I create the plot:我创建了 plot:

fig = px.scatter_3d(df, x='xvalues', y='yvalues', z='zvalues')

I change the markers我改变了标记

fig.update_traces(marker=dict(
        color='lightblue',
        size=10,
        line=dict(color='purple',
                  width=3
        )))

colors and everything work, but there's either no line if I set the width to 0 or there is a line for every other value but it seems to be 1 px wide. colors 并且一切正常,但是如果我将宽度设置为 0 则没有线,或者每个其他值都有一条线,但它似乎是 1 px 宽。

I also tried我也试过

fig.data[0].marker.line.width=3

which shows the exact same behavior.这显示了完全相同的行为。 Line is gone when set to 0, line is 1 px wide when set to any other value.设置为 0 时线条消失,设置为任何其他值时线条为 1 px 宽。

Is there a way to fix this?有没有办法来解决这个问题? Sadly the documentation isn't very good.可悲的是,文档不是很好。

Line dict should not be inside marker.行 dict 不应在标记内。 Try this:尝试这个:

fig.update_traces(
    marker=dict(
        color='lightblue',
        size=10),
    line=dict(
        color='purple',
        width=3
    )
)

What I mean, you havn't set your brackets correctly我的意思是,您没有正确设置括号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM