python - 如何巧妙地不忽略我的轴设置?

标签 python plotly

import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)

import numpy as np

x, y, z = np.random.multivariate_normal(np.array([0,0,0]), np.eye(3), 200).transpose()
trace1 = go.Scatter3d(
    x=x,
    y=y,
    z=z,
    mode='markers',
    marker=dict(
        size=12,
        line=dict(
            color='rgba(217, 217, 217, 0.14)',
            width=0.5
        ),
        opacity=0.8
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    ),
    xaxis=dict(type='log',
               autorange=True,
               title="L1")
)
fig = go.Figure(data=data, layout=layout)
iplot(fig, filename='simple-3d-scatter')

这是文档中的示例,https://plot.ly/python/3d-scatter-plots/我稍微修改为

  • 制作 xaxis 对数刻度(遵循 this )和
  • 更改 x 轴标签(在 this 之后)

但是,Plotly 似乎(默默地)忽略了我的轴设置,因为我得到了这个并且没有收到任何错误/警告:

enter image description here

您可能会注意到,我希望它具有的既不是对数刻度也不是 L1 轴标签。

我该如何解决这个问题? Python 3.6.8,Plotly 版本 3.6.1,在 Jupyter notebook 中绘图(离线模式)。


在 virtualenv 中尝试 plotly 3.3:

enter image description here

最佳答案

scene 字典中指定轴属性,如下所示:

layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    ),
    scene=dict(
        xaxis=dict(
           type='log',
           autorange=True,
           title='L1')
    )
)

enter image description here

关于python - 如何巧妙地不忽略我的轴设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55447473/

相关文章:

python - 使用 PySide 和 QTextEdit 半透明突出显示

python - 在没有在线 plotly 帐户的情况下使用 plotly

python - 在plotlyexpress中添加甘特图的超链接?

Python - 动态导入模块并为其分配本地名称

python - 'str' 对象不能被解释为 python 中的整数

r - 绘图标记大小

R从多列绘制x轴标签

python - Plotly:如何获取跟踪颜色属性以绘制具有相同颜色的选定标记?

python - 确定集合并集的有效方法

python - 无法将 python 包下载到 Docker 镜像中