{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### New to Plotly?\n",
"Plotly's Python library is free and open source! [Get started](https://plotly.com/python/getting-started/) by downloading the client and [reading the primer](https://plotly.com/python/getting-started/).\n",
"
You can set up Plotly to work in [online](https://plotly.com/python/getting-started/#initialization-for-online-plotting) or [offline](https://plotly.com/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plotly.com/python/getting-started/#start-plotting-online).\n",
"
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Overview\n",
"This notebook demonstrates how to use DataShader to display large datasets inside a plotly `FigureWidget`. Change callbacks are used to recompute the datashader image whenever the axis range or figure size changes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Imports"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# core\n",
"import io\n",
"import base64 \n",
"import time\n",
"\n",
"# pandas\n",
"import pandas as pd\n",
"\n",
"# numpy\n",
"import numpy as np\n",
"\n",
"# scikit learn\n",
"from sklearn import datasets\n",
"\n",
"# datashader\n",
"import datashader as ds\n",
"import datashader.transfer_functions as tf\n",
"from datashader.colors import inferno"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Generate dataset\n",
"We will create a large dataset by duplicating the Iris dataset many times with random noise"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
| \n", " | sepal_length | \n", "sepal_width | \n", "petal_length | \n", "petal_width | \n", "
|---|---|---|---|---|
| count | \n", "1.050000e+06 | \n", "1.050000e+06 | \n", "1.050000e+06 | \n", "1.050000e+06 | \n", "
| mean | \n", "5.843322e+00 | \n", "3.053826e+00 | \n", "3.758637e+00 | \n", "1.198662e+00 | \n", "
| std | \n", "8.488862e-01 | \n", "4.761369e-01 | \n", "1.769910e+00 | \n", "7.865315e-01 | \n", "
| min | \n", "3.513149e+00 | \n", "1.299055e+00 | \n", "3.115114e-01 | \n", "-6.631019e-01 | \n", "
| 25% | \n", "5.156767e+00 | \n", "2.740113e+00 | \n", "1.636770e+00 | \n", "3.929785e-01 | \n", "
| 50% | \n", "5.801633e+00 | \n", "3.033015e+00 | \n", "4.306745e+00 | \n", "1.316042e+00 | \n", "
| 75% | \n", "6.443514e+00 | \n", "3.345643e+00 | \n", "5.143670e+00 | \n", "1.827473e+00 | \n", "
| max | \n", "8.598814e+00 | \n", "5.109186e+00 | \n", "7.763358e+00 | \n", "3.267767e+00 | \n", "
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Reference"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"See [these Jupyter notebooks](https://github.com/jonmmease/plotly_ipywidget_notebooks) for even more FigureWidget examples."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"