Skip to content

Commit

Permalink
Update example notebook.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Nov 12, 2024
1 parent 716dbbd commit 01d828d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 489 deletions.
139 changes: 25 additions & 114 deletions docs/PlotlyViewerExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "75a31f1b-a32a-42ba-a016-f324faa9f3a7",
"metadata": {},
"outputs": [],
Expand All @@ -40,28 +40,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "0746adc6-dbe1-4f85-8690-da24458667c0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['ipyvolume:lasso', 'ipyvolume:circle', 'ipyvolume:rectangle']\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/jon/opt/mambaforge/envs/glue-plotly/lib/python3.11/site-packages/glue_qt/viewers/common/tool.py:5: UserWarning:\n",
"\n",
"glue.viewers.common.tool is deprecated, use glue.viewers.common.tool instead\n",
"\n"
]
}
],
"outputs": [],
"source": [
"app = jglue()\n",
"session = app.session\n",
Expand All @@ -78,23 +60,23 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"id": "95d749da-73c8-432a-9a23-85d37e1b6fb5",
"metadata": {},
"outputs": [],
"source": [
"from random import randint\n",
"x = [randint(0, 100) for _ in range(100)]\n",
"y = [randint(300, 400) for _ in range(100)]\n",
"data = app.load_data(\"~/dev/glue/data/airplane/planes_truncated.csv\")\n",
"data = Data(label='data', x=x, y=y)\n",
"dc.append(data)\n",
"data.style.color = \"#0000ff\"\n",
"data.style.markersize = 6"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "92745ee0-25bf-455a-b022-045059fa8e19",
"metadata": {},
"outputs": [],
Expand All @@ -119,25 +101,10 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"id": "cf42768e-6d31-4375-90ee-facd8d19800a",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a086592611844e8d94a1c6623d35cb5a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"LayoutWidget(controls={'toolbar_selection_tools': BasicJupyterToolbar(template=Template(template='<template>\\n…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"scatter_viewer = app.new_data_viewer(\"plotly_scatter\", data=data)\n",
"# Alternatively, you can use the viewer class:\n",
Expand All @@ -146,33 +113,20 @@
},
{
"cell_type": "code",
"execution_count": 28,
"id": "d94774d4-3a68-4b7a-b7f2-7e79afead2b5",
"execution_count": null,
"id": "cbeeb763-daf0-4828-8535-f05f97ec856f",
"metadata": {},
"outputs": [],
"source": [
"scatter_viewer.state.x_axislabel = \"Longitude\"\n",
"scatter_viewer.state.y_axislabel = \"Latitude\"\n",
"scatter_viewer.figure.layout.width = 900"
"scatter_viewer.add_data(data2)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "1355c76d-ad3d-4202-a08f-ee17b1facbd4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(PlotlyScatterLayerArtist for My Data, PlotlyScatterLayerArtist for data2)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"scatter_viewer.layers"
]
Expand All @@ -187,46 +141,20 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "da0a70ee-f299-47cd-9eb0-9a634d983c02",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"scatter_viewer.layers[1].state.zorder"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "3e66be74-929f-4cfa-910c-9d3b65b4ac91",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e72117c63af0431a91224959cfdbf10b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"LayoutWidget(controls={'toolbar_selection_tools': BasicJupyterToolbar(template=Template(template='<template>\\n…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"histogram_viewer = app.new_data_viewer(\"plotly_histogram\", data=data)\n",
"# Alternatively, you can use the viewer class:\n",
Expand All @@ -243,15 +171,13 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"id": "821b6397-80e2-443c-b6c3-50bf954abbf2",
"metadata": {},
"outputs": [],
"source": [
"histogram_viewer.state.gaps = True\n",
"histogram_viewer.state.gap_fraction = 0.13\n",
"histogram_viewer.state.x_axislabel = \"Value\"\n",
"histogram_viewer.figure.layout.width = 900"
"histogram_viewer.state.gap_fraction = 0.15"
]
},
{
Expand All @@ -265,7 +191,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"id": "4f9d9ffe-ec2e-4d7f-aa8b-8b2a7524b9c2",
"metadata": {},
"outputs": [],
Expand All @@ -280,25 +206,10 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "174cd945-0744-43dc-b23e-bcef244a0bff",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4aef2c287aca4be08ac525f96db1510e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"LayoutWidget(controls={'toolbar_selection_tools': BasicJupyterToolbar(template=Template(template='<template>\\n…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"dotplot_viewer = app.new_data_viewer(DotplotViewer, data=data)"
]
Expand All @@ -314,9 +225,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "glue-plotly",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "glue-plotly"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -328,7 +239,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 01d828d

Please sign in to comment.