gpt4 book ai didi

python - 将轴标题添加到 3D 曲面图袖扣和绘图

转载 作者:太空宇宙 更新时间:2023-11-03 20:44:29 26 4
gpt4 key购买 nike

有人可以给我一些关于如何将 x,y,z 轴标题添加到使用plotly & cufflinks 创建的 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)

enter image description here

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com