Plotly 绘制表面 3D 未显示

Plotly Plot surface 3D not displayed(Plotly 绘制表面 3D 未显示)
本文介绍了Plotly 绘制表面 3D 未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的在论坛上找不到答案.我想用 plotly 离线创建一个 3d 表面.我使用样本点.场景显示为空而没有表面.请帮忙,谢谢.

I really can't find an answer on the forum. I want to create a 3d surface with plotly offline. I use sample points. The scene displays empty without a surface. Please help, thanks.

import pandas as pd
import numpy as np
from plotly.offline import download_plotlyjs, init_notebook_mode, plot
from plotly.graph_objs import *
init_notebook_mode()
df3=pd.DataFrame({'x':[1,2,3,4,5], 'y':[10,20,30,20,10], 'z':[5,4,3,2,1]})

trace0= Surface(x=df3['x'], y=df3['y'], z=df3['z'])
data=[trace0]
fig=dict(data=data)
plot(fig)

推荐答案

问题是你还没有定义数据的表面,因为你的 z 数据只是一维的.例如,这应该显示一个表面:

The problem is you haven't defined a surface of data, since your z data is just one-dimensional. For example, this should show a surface:

import pandas as pd
import numpy as np
from plotly.offline import download_plotlyjs, init_notebook_mode, plot
from plotly.graph_objs import *
init_notebook_mode()

df3=pd.DataFrame({
    'x':[1,2,3,4,5],
    'y':[10,20,30,20,10],
    'z':[[5,4,3,2,1]] * 5
})

trace0= Surface(x=df3['x'], y=df3['y'], z=df3['z'])
data=[trace0]
fig=dict(data=data)
plot(fig)

这篇关于Plotly 绘制表面 3D 未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Leetcode 234: Palindrome LinkedList(Leetcode 234:回文链接列表)
How do I read an Excel file directly from Dropbox#39;s API using pandas.read_excel()?(如何使用PANDAS.READ_EXCEL()直接从Dropbox的API读取Excel文件?)
subprocess.Popen tries to write to nonexistent pipe(子进程。打开尝试写入不存在的管道)
I want to realize Popen-code from Windows to Linux:(我想实现从Windows到Linux的POpen-code:)
Reading stdout from a subprocess in real time(实时读取子进程中的标准输出)
How to call type safely on a random file in Python?(如何在Python中安全地调用随机文件上的类型?)