try:
    import pycandela
except ImportError:
    # Import hack for when in the pycandela source tree.
    import sys
    sys.path.append('..')
    import pycandela

"""
Explanation: Iris
This notebook loads the Iris data (attributes of flower species) and displays a few scatterplots with Candela.
End of explanation
"""


import requests
data = requests.get('https://raw.githubusercontent.com/vega/vega-datasets/gh-pages/data/iris.json').json()

pycandela.components.ScatterPlotMatrix(
    data=data, color='species', fields=['sepalLength', 'sepalWidth', 'petalLength', 'petalWidth'], width=800)

"""
Explanation: Scatterplot matrix of JSON data
Candela supports the list-of-records data format, for example [{'x': 0, 'y': 0},{'x': 1, 'y': 2}, ...].
End of explanation
"""


from pandas import DataFrame
df = DataFrame.from_records(data)

pycandela.components.ScatterPlot(data=df, color='species', x='sepalLength', y='sepalWidth')

"""
Explanation: Scatterplot of a DataFrame
The data may also be sent to Candela as a pandas DataFrame.
End of explanation
"""


