Data Visualization in Python

In [2]:
import plotly as py
import plotly.graph_objs as go
import ipywidgets as widgets
import numpy as np
from scipy import special

py.offline.init_notebook_mode(connected=True)
In [21]:
x = np.linspace(0, np.pi, 1000)

layout = go.Layout(
    title="Simple Example",
    yaxis=dict(
        title='volts',
    ),
    xaxis=dict(
        title='nanoseconds'
    )
)
data=[

]
trace1 = go.Scatter(
    x=x,
    y=np.cos(x),
    mode='lines',
    name='bessel {}'.format(x),
    line=dict(
        shape='spline'
    )
)

data.append(trace1)

fig = go.Figure(data=data, layout=layout)
py.offline.iplot(fig)
#     py.plotly.iplot(fig)

# signals = widgets.SelectMultiple(options=list(range(6)), value=(0,), description='Bessel Order')
# freq = widgets.FloatSlider(min=1, max=20,value=1, description='Freq')
# widgets.interactive(update_plot, signals=signals, freq=freq)
In [17]:
x = np.linspace(0, np.pi, 1000)

layout = go.Layout(
    title="Simple Example",
    yaxis=dict(
        title='volts',
    ),
    xaxis=dict(
        title='nanoseconds'
    )
)

def update_plot(signals, freq):

    data = []
    for s in signals:
        trace1 = go.Scatter(
            x=x,
            y=special.jv(s, freq * x),
            mode='lines',
            name='bessel {}'.format(s),
            line=dict(
                shape='spline'
            )
        )

        data.append(trace1)

    fig = go.Figure(data=data, layout=layout)
    py.offline.iplot(fig)
#     py.plotly.iplot(fig)

signals = widgets.SelectMultiple(options=list(range(6)), value=(0,), description='Bessel Order')
freq = widgets.FloatSlider(min=1, max=20,value=1, description='Freq')
widgets.interactive(update_plot, signals=signals, freq=freq)
In [ ]: