ipython ノートブック 3.0.0
matplotlib 1.4.3
OS X 10.11.4
3D データ キューブのインタラクティブな 3D 散布図を作成しています。ここに、データ キューブをプロットしようとして遭遇したのと同じ問題を生成するおもちゃの例を含めました。
ノートブックの外で matplot ウィンドウを生成した場合、手動で閉じる (赤い x をクリックする) と、強制終了するまで「ホイール」で停止します。
#Generate matplot window outside of the notebook
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
#from matplot3d tutorial
def randrange(n, vmin, vmax):
return (vmax - vmin)*np.random.rand(n) + vmin
fig = plt.figure() ax = fig.add_subplot(111, projection='3d') n = 100 for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
xs = randrange(n, 23, 32)
ys = randrange(n, 0, 100)
zs = randrange(n, zl, zh)
ax.scatter(xs, ys, zs, c=c, marker=m)
ax.set_xlabel('X Label') ax.set_ylabel('Y Label') ax.set_zlabel('Z Label')
plt.show()
ノートブック内で mpld3 を使用しようとしましたが、インタラクティブでない画像がエラーと共に表示されます
「TypeError: array([ 2., 20.]) は JSON シリアライズ可能ではありません」
#Use mpld3 within notebook
import matplotlib.pyplot as plt
import numpy as np
import mpld3
from mpl_toolkits.mplot3d import Axes3D
mpld3.enable_notebook()
def randrange(n, vmin, vmax):
return (vmax - vmin)*np.random.rand(n) + vmin
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n = 100
for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
xs = randrange(n, 23, 32)
ys = randrange(n, 0, 100)
zs = randrange(n, zl, zh)
ax.scatter(xs, ys, zs, c=c, marker=m)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
JSON シリアライゼーションに関するいくつかの簡単な調査は実りがありませんでした。
ストールしないインタラクティブな 3D matplotlib 散布図を作成する最良の方法は何ですか?