Converting Matplotlib example results in dang!


#1

I tried running the code below but I get the following warning:

/Users/diego/anaconda/lib/python3.5/site-packages/plotly/matplotlylib/renderer.py:445: UserWarning:
Dang! That path collection is out of this world. I totally don’t know what to do with it yet! Plotly can only import path collections linked to ‘data’ coordinates

The resulting figure looks like:

If I remove the only iplotly line, I get the desired figure (cant link to it as new users can only post one link - add the .png back to the link), which has a 3d surface on the left
https://s31.postimg.org/n5nq2g6ez/img DOT PNG

Code:

# imports
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import plotly.plotly as py
from plotly.graph_objs import *
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from IPython.html.widgets import interact, fixed, FloatSlider  

x = np.arange(-5, 5, 0.25)              # points in the x axis
y = np.arange(-5, 5, 0.25)              # points in the y axis
X, Y = np.meshgrid(x, y)                # create the "base grid"
Z = X**2 - Y**2    

fig = plt.figure(figsize=(20,5))

# 3D Plot
ax1 = fig.add_subplot(1, 3, 1, projection='3d')
surf = ax1.plot_surface(X, Y, Z,             # data values (2D Arryas)
                       rstride=2,           # row step size
                       cstride=2,           # column step size
                       cmap=cm.RdPu,        # colour map
                       linewidth=0,         # wireframe line width
                       antialiased=True)

ax1.plot(np.ones_like(x)*x_val,y,(x_val)**2-y**2, 'r--');
ax1.plot(x,np.ones_like(y)*y_val,x**2-(y_val)**2, 'b--');
ax1.set_xlabel('x axis')
ax1.set_ylabel('y axis')
ax1.set_zlabel('z axis')
ax1.set_title('3D Surface')

# 2D Slice
ax2 = fig.add_subplot(2,3,2)
ax2.plot(y,(x_val)**2-y**2, 'r--');
ax2.set_xlim(-5,5)
ax2.set_xlabel('y axis')
ax2.set_ylim(-30,30)
ax2.set_ylabel('z axis')
ax2.set_title('Y 2D Slice')

# Derivative
ax3 = fig.add_subplot(2,3,3)
ax3.plot(y,-2*y)
ax3.set_xlim(-5,5)
ax3.set_xlabel('y axis')
ax3.set_ylim(-30,30)
ax3.set_ylabel('z axis')
ax3.set_title('Derivative')


# 2D Slice
ax2 = fig.add_subplot(2,3,5)
ax2.plot(x,x**2-(y_val)**2, 'b--');
ax2.set_xlim(-5,5)
ax2.set_xlabel('x axis')
ax2.set_ylim(-30,30)
ax2.set_ylabel('z axis')
ax2.set_title('X 2D Slice')

# Derivative
ax3 = fig.add_subplot(2,3,6)
ax3.plot(x,2*x)
ax3.set_xlim(-5,5)
ax3.set_xlabel('x axis')
ax3.set_ylim(-30,30)
ax3.set_ylabel('z axis')
ax3.set_title('Derivative')
    
py.iplot_mpl(fig)

#2

try using offline plot.
from plotly import offline
offline.plot(figure,auto_open=True)