3

using matplotlib I can make an interactive 3D plot in jupyter notebook . I use the following example code . It s easy and not the problem. But after converting the notebook in html, the interactive 3D plot became non-interactive. I mean, it can not be rotated like before. It is just a static image. I used menue File->Download as -> HTML to convert the notebook to html file. But I just want to keep the interactivity even after converting. Does anyone have a good idea?

I have already known that there is a way for 2D interactive plot. But I can not find any idea to do this for a 3D interactive plot.

Thanks for any idea.

'''
==============
3D scatterplot
==============

Demonstration of a basic scatterplot in 3D.
'''
%matplotlib notebook
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation

def randrange(n, vmin, vmax):
    '''
    Helper function to make an array of random numbers having shape (n, )
    with each number distributed Uniform(vmin, vmax).
    '''
    return (vmax - vmin)*np.random.rand(n) + vmin

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

n = 100

# For each set of style and range settings, plot n random points in the box
# defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh].
for c, m, zlow, zhigh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
    xs = randrange(n, 23, 32)
    ys = randrange(n, 0, 100)
    zs = randrange(n, zlow, zhigh)
    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()
wayag
  • 81
  • 4
  • What does "I have already known that there is a way for 2D interactive plot." mean? In how far is this way failing for 3D? – ImportanceOfBeingErnest May 03 '18 at 20:55
  • I read the link https://stackoverflow.com/questions/22739592/how-to-embed-an-interactive-matplotlib-plot-in-a-webpage. But there is not direct example to show how to deal with 3D case. Plotly is maybe usefull, but you need to create a user-account and use some API-Key, that ist not what I want. I just want to get a totally free one. – wayag May 04 '18 at 08:56
  • Plotly does not require a user account or to pay anything (this is just if you want to share your stuff over the webservice). – ImportanceOfBeingErnest May 04 '18 at 10:58
  • Yes you are right!. Thanks a lot. – wayag May 06 '18 at 20:11

0 Answers0