谁能给我一个小贴士,介绍如何将x,y,z轴标题添加到使用plotly和袖扣创建的3个表面图上?

我正在使用Jupyter笔记本Anaconda 3.7

import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import iplot, init_notebook_mode
# Using plotly + cufflinks in offline mode
import cufflinks
cufflinks.go_offline(connected=True)
init_notebook_mode(connected=True)

import pandas as pd
import numpy as np

# creating dataframe with three axes
df = pd.DataFrame({'x':[1, 2, 3, 4, 5],
                    'y':[10, 20, 30, 20, 10],
                    'z':[5, 4, 3, 2, 1]})

# colorscale:red(rd), yellow(yl), blue(bu)
df.iplot(kind ='surface', colorscale ='rdylbu')


任何提示都可以帮助您。

最佳答案

你去了:

import plotly
import plotly.graph_objs as go
plotly.offline.init_notebook_mode(connected=True)
import pandas as pd

# creating dataframe with three axes
data = pd.DataFrame({'x':[1, 2, 3, 4, 5],
                    'y':[10, 20, 30, 20, 10],
                    'z':[5, 4, 3, 2, 1]})

data = [
    go.Surface(
        z = data.as_matrix()
    )
]
layout = go.Layout(
    title='My Surface',
    autosize=False,
    width=1000,
    height=600,
    margin=dict(
        l=65,
        r=50,
        b=65,
        t=90
    ),
    scene = {"xaxis":{"title":"my x axis name"},
             "yaxis":{"title":"my pretty y axis name"},
             "zaxis":{"title":"Z AXIS"}}
)
fig = go.Figure(data=data, layout=layout)

plotly.offline.plot(fig)


python - 将轴标题添加到3d曲面图袖扣并进行绘图-LMLPHP

关于python - 将轴标题添加到3d曲面图袖扣并进行绘图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56686913/

10-11 00:45