2

I want to send a Matplotlib interactive 3D plot to non-python users so that they can rotate and zoom in/out the figure. For example, the code below generates a simple 3D bar graph but can't be read if Python is not installed.

I have tried compiling with PyInstaller and read pickle.dumb file (no figure displayed) , using mpld3 functions (get TypeError: Object of type ndarray is not JSON serializable), using the libscript module as suggested in previous thread (Saving interactive Matplotlib figures) without success.

''''

from  mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

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

xpos = [1,2,3,4,5,6,7,8,9,10]
ypos = [2,3,4,5,1,6,2,1,7,2]
zpos = [0,0,0,0,0,0,0,0,0,0]

dx = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
dy = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
dz = [1,2,3,4,5,6,7,8,9,10]


ax1.bar3d(xpos, ypos,zpos, dx, dy, dz, color = '#00ceaa')
plt.show()

''''

Grothen
  • 33
  • 5
  • You can indeed put it into an executable and ship that to users. Else, users need python to interactively use a matplotlib figure. Potentially you can have python running on a server - so shipping a (link to a) notebook which users will open in a browser and which connects to a notebook server might be an option. THe same would work with the webagg backend and a server running python. Else consider using plotly instead. That would run its javascript code in the browser. – ImportanceOfBeingErnest Nov 11 '19 at 17:10
  • [Mayavi](https://docs.enthought.com/mayavi/mayavi/mlab.html) is possibly a better alternative to matplotlib for this, as it exports on a multitude of stand-alone formats. – ezatterin Nov 11 '19 at 18:12

0 Answers0