Plotly - Tracer en ligne avec Jupyter Notebook

Dans ce chapitre, nous étudierons comment effectuer un traçage en ligne avec le bloc-notes Jupyter.

Pour afficher le tracé dans le cahier, vous devez lancer le mode cahier de tracé comme suit -

from plotly.offline import init_notebook_mode
init_notebook_mode(connected = True)

Conservez le reste du script tel quel et exécutez la cellule du bloc-notes en appuyant sur Shift+Enter. Le graphique sera affiché hors ligne à l'intérieur du notebook lui-même.

import plotly
plotly.tools.set_credentials_file(username = 'lathkar', api_key = '************')
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode(connected = True)

import plotly
import plotly.graph_objs as go
import numpy as np
import math #needed for definition of pi

xpoints = np.arange(0, math.pi*2, 0.05)
ypoints = np.sin(xpoints)
trace0 = go.Scatter(
   x = xpoints, y = ypoints
)
data = [trace0]
plotly.offline.iplot({ "data": data,"layout": go.Layout(title="Sine wave")})

La sortie du notebook Jupyter sera comme indiqué ci-dessous -

La sortie du tracé montre un tool bar à top right. Il contient des boutons à télécharger commepng, zoom in and out, box and lasso, select and hover.