【发布时间】:2021-09-22 23:20:51
【问题描述】:
我有下面给出的数据,我想在 z 轴上绘制具有 x 和 y 值频率的交互式曲面图
**apples** **oranges**
0 1
10 2
20 1
10 1
10 1
我试过下面的代码
import plotly.graph_objects as go
import pandas as pd
import numpy as np
#
z_data = df.groupby(['apples', 'oranges']).count()
x, y = df['apples'], df['oranges']
sh_0, sh_1 = z.shape
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])
#fig.update_layout(title='histogram_trial', autosize=True)
fig.update_layout(title='Mt Bruno Elevation', autosize=False,
width=500, height=500,
margin=dict(l=65, r=50, b=65, t=90))
fig.show()
上面的代码给了我空白输出。请告诉我如何获得 z 轴的计数
【问题讨论】:
-
当你说z轴上x和y值的频率时,你能解释一下你的意思吗?每个 x 和 y 值的预期 z 值是多少?
-
嗨 Derek,我的 z 值应该如下所示 apples oranges ** z** 0 1 1 10 2 1 20 1 1 10 1 2
标签: python matplotlib plotly frequency