关于python:将轴标题添加到3d曲面图袖扣并进行绘图

add axis titles to 3d surface plot cufflinks & plotly

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

我正在使用Jupyter笔记本Anaconda 3.7

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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')

任何提示都可以帮助您。


你去了:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)

enter image description here