我使用Jupyter Notebook对数据集进行分析。笔记本中有很多情节,其中一些是3d情节。

我想知道是否有可能让3d绘图具有交互性,这样我以后可以更详细地使用它?
也许我们可以在上面加个按钮?点击它可以弹出一个3d图,人们可以缩放,平移,旋转等。
我的想法是:
1. matplotlib,%qt
这不适合我的情况,因为我需要在3d打印后继续打印。%qt将干扰以后的绘图。
2. mpld3
在我的情况下,mpld3几乎是理想的,不需要重写任何东西,与matplotlib兼容。但是,它只支持二维打印。我没有看到任何关于3D (https://github.com/mpld3/mpld3/issues/223)的计划。
3. bokeh + visjs
在bokeh画廊中没有找到任何实际的3d绘图示例。我只找到了使用visjs的https://demo.bokeh.org/surface3d。
4. Javascript 3D绘图?
由于我需要的只是line和surce,是否可以在浏览器中使用js将数据传递到js plot以使其具有交互性?(然后我们可能还需要添加3d轴。)这可能类似于visjs和mpld3。
发布于 2016-08-10 14:13:13
尝试:
%matplotlib notebook
针对JupyterLab用户的编辑:
按照instructions安装jupyter-matplotlib
则不再需要上面的魔术命令,如下例所示:
# Enabling the `widget` backend.
# This requires jupyter-matplotlib a.k.a. ipympl.
# ipympl can be install via pip or conda.
%matplotlib widget
# aka import ipympl
import matplotlib.pyplot as plt
plt.plot([0, 1, 2, 2])
plt.show()发布于 2017-05-25 01:35:03
the documentation shows live demos,有一个名为ipyvolume的新库可以做你想做的事情。当前版本不支持网格和线条,但git代码库中的master支持(0.4版)。(免责声明:我是作者)
发布于 2018-11-23 19:10:41
您可以使用Plotly库。它可以直接在Jupyter Notebook中渲染交互式3D绘图。
为此,您首先需要通过运行以下命令来安装Plotly:
pip install plotly您可能还希望通过运行以下命令来升级库:
pip install plotly --upgrade然后,在你的Jupyter Notebook中,你可以这样写:
# Import dependencies
import plotly
import plotly.graph_objs as go
# Configure Plotly to be rendered inline in the notebook.
plotly.offline.init_notebook_mode()
# Configure the trace.
trace = go.Scatter3d(
x=[1, 2, 3], # <-- Put your data instead
y=[4, 5, 6], # <-- Put your data instead
z=[7, 8, 9], # <-- Put your data instead
mode='markers',
marker={
'size': 10,
'opacity': 0.8,
}
)
# Configure the layout.
layout = go.Layout(
margin={'l': 0, 'r': 0, 'b': 0, 't': 0}
)
data = [trace]
plot_figure = go.Figure(data=data, layout=layout)
# Render the plot.
plotly.offline.iplot(plot_figure)因此,将在Jupyter Notebook中为您绘制以下图表,您将能够与其进行交互。当然,您需要提供您的特定数据,而不是建议的数据。

https://stackoverflow.com/questions/38364435
复制相似问题