import ipywidgets as widgets

slider = widgets.FloatSlider(min=0, max=10, step=0.5)
slider

text = widgets.FloatText(value=1)
text

text.value

text.value = 5
slider.value = 2

widgets.jslink((text, 'value'), (slider, 'value'))

slider.value = 3.0

"""
Explanation: Ipywidgets

Interactive widgets for the Jupyter notebook
Documentation: https://ipywidgets.readthedocs.io
Github: https://github.com/jupyter-widgets/ipywidgets
End of explanation
"""


import bqplot.pyplot as plt
import numpy as np

x = np.linspace(0, 2, 50)
y = x**2

fig = plt.figure()
scatter = plt.scatter(x, y)
plt.show()

fig.animation_duration = 500
scatter.y = x**0.5

scatter.selected_style = {'stroke':'red', 'fill': 'orange'}
plt.brush_selector();

scatter.selected

scatter.selected = [1,2,10,40]

"""
Explanation: Bqplot

Interactive plotting in the Jupyter notebook
Documentation: https://bqplot.readthedocs.io
Github: https://github.com/bloomberg/bqplot
End of explanation
"""


import ipyleaflet
ipyleaflet.Map(center = [48.7142971, 2.209103], zoom = 14)

_.add_layer(ipyleaflet.ImageOverlay(url='https://jupyter.org//assets/nav_logo.svg', bounds=_.bounds, opacity=0.8))

"""
Explanation: Other widget libraries

pythreejs (3d vis)
ipysheet (spreadsheet)
ipypivot
...

Ipyleaflet

leaflet / Jupyter bridge enabling interactive maps in the notebook
https://github.com/ellisonbg/ipyleaflet
End of explanation
"""


import vaex
import numpy as np
np.warnings.filterwarnings('ignore')
dstaxi = vaex.open('nyc_taxi2015.hdf5') # mmapped, doesn't cost extra memory

dstaxi.plot_widget("pickup_longitude", "pickup_latitude", f="log", backend="ipyleaflet", shape=600)

dstaxi.plot_widget("dropoff_longitude", "dropoff_latitude", f="log", backend="ipyleaflet",
                   z="dropoff_hour", type="slice", z_shape=24, shape=400, z_relative=True,
                   limits=[None, None, (-0.5, 23.5)])

ds = vaex.open('helmi-dezeeuw-2000-FeH.hdf5')

ds.plot_widget("x", "y", f="log", limits=[-20, 20])

ds.plot_widget("Lz", "E", f="log")

"""
Explanation: Integration with vaex
End of explanation
"""


import ipyvolume as ipv
import numpy as np
np.warnings.filterwarnings('ignore')

ipv.example_ylm();

N = 1000
x, y, z = np.random.random((3, N))

fig = ipv.figure()
scatter = ipv.scatter(x, y, z, marker='box')
ipv.show()

scatter.x = scatter.x + 0.1

scatter.color = "green"
scatter.size = 5

scatter.color = np.random.random((N,3))

scatter.size = 2

ipv.figure()
ipv.style.use('dark')
quiver = ipv.quiver(*ipv.datasets.animated_stream.fetch().data[:,::,::4], size=5)
ipv.animation_control(quiver, interval=200)
ipv.show()

ipv.style.use('light')

quiver.size = np.random.random(quiver.x.shape) * 10

quiver.color = np.random.random(quiver.x.shape + (3,))

quiver.geo = "cat"

# stereo

quiver.geo = "arrow"

N = 1000*1000
x, y, z = np.random.random((3, N)).astype('f4')

ipv.figure()
s = ipv.scatter(x, y, z, size=0.2)
ipv.show()

s.size = 0.1

#ipv.screenshot(width=2048, height=2048)

plot3d = ds.plot_widget("x", "y", "z", vx="vx", vy="vy", vz="vz",
                        backend="ipyvolume", f="log1p", shape=100, smooth_pre=0.5)

plot3d.vcount_limits = [70, 100000]

plot3d.backend.quiver.color = "red"

import ipywidgets as widgets

widgets.ColorPicker()

widgets.jslink((plot3d.backend.quiver, 'color'), (_, 'value'))

ipv.save("jupyter-day-paris-2018.html")

!open jupyter-day-paris-2018.html

"""
Explanation: ipyvolume

3d plotting for Python in the Jupyter notebook based on IPython widgets using WebGL
Glyphs, volume rendering, surfaces/meshes/lines/isosurfaces
Live documentation http://ipyvolume.readthedocs.io/en/stable/
End of explanation
"""


