任何人都可以给我一些技巧,向如何通过plotly&袖扣创建的3个表面绘图添加x,y,z轴标题吗?
我正在使用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')
任何提示都可以帮助您。
答案 0 :(得分:0)
去那里:
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)