Ask Your Question
2

Plotly/Cufflinks and Jupyter Notebooks

asked 2018-04-02 02:33:25 +0100

spacebump gravatar image

The code below is my attempt to use plotly offline to display the Lorenz attractor. The exact same code works on a Jupyter notebook that I host locally, but not in CoCalc. I've checked to make sure that all of the necessary packages are available and up to date.

Instead of a plot, I get a "Fetch additional output..." button that says "WARNING: 1 intermediate output message was discarded."

import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
import pandas as pd
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
import cufflinks as cf
cf.go_offline()
%matplotlib inline

def dx(x,y,z):
    return 10*(y-x)
def dy(x,y,z):
    return x*(28-z)-y
def dz(x,y,z):
    return x*y-(8/3)*z

y0 = [1,1,1]

t = np.linspace(0,100,10000)

def f(y,t):
    return [dx(y[0],y[1],y[2]),dy(y[0],y[1],y[2]),dz(y[0],y[1],y[2])]

sol = odeint(f,y0,t)

df = pd.DataFrame({'x':sol[:,0],'y':sol[:,1],'z':sol[:,2]})

df.iplot(kind='scatter3d',x='x',y='y',z='z')
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2018-04-03 00:36:59 +0100

slelievre gravatar image

updated 2018-04-03 00:51:07 +0100

CoCalc uses its own implementation of Jupyter notebooks.

If any functionality is not working there, you can revert to the standard implementation.

For that, visit your CoCalc project's settings, and in the "Jupyter notebook server" section of the project settings, click on "Plain Jupyter Server".

Using the "Plain Jupyter Server" in CoCalc, running a Python2 kernel for example, the code in the question works fine and displays a Lorenz attractor.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-04-02 02:33:25 +0100

Seen: 1,533 times

Last updated: Apr 03 '18