diff --git a/README.rst b/README.rst index 44e2853..f605c8f 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ Experimental plot.ly plugin for glue ------------------------------------ -This package is a plugin for `glue `_ that allows functionality linking glue +This package is a plugin for `glue `_ that allows linking glue to `Plotly `_. This includes three main pieces of functionality: - Export glue views to standalone HTML pages diff --git a/doc/PlotlyViewerExample.ipynb b/doc/PlotlyViewerExample.ipynb index fa1ef8a..ccbc943 100644 --- a/doc/PlotlyViewerExample.ipynb +++ b/doc/PlotlyViewerExample.ipynb @@ -1,8 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "id": "d5103242-a264-4f98-a168-ab40087f8c0c", + "metadata": {}, + "source": [ + "# Plotly Viewer Examples\n", + "This notebook contains examples of how to use the viewers provided by the `glue-plotly` package" + ] + }, + { + "cell_type": "markdown", + "id": "9101e7af-1a3a-4152-b43f-829c52a3d166", + "metadata": {}, + "source": [ + "### Imports" + ] + }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "75a31f1b-a32a-42ba-a016-f324faa9f3a7", "metadata": {}, "outputs": [], @@ -13,42 +30,37 @@ "from glue_plotly.viewers.scatter.viewer import PlotlyScatterView" ] }, + { + "cell_type": "markdown", + "id": "c015dc70-746f-415b-853f-c31ea92cff67", + "metadata": {}, + "source": [ + "Create a glue-jupyter application and session" + ] + }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "0746adc6-dbe1-4f85-8690-da24458667c0", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/jon/opt/mambaforge/envs/glue-plotly/lib/python3.11/site-packages/glue/qglue.py:4: GlueDeprecationWarning: Importing from glue.qglue is deprecated, use glue_qt.qglue instead\n", - " warnings.warn('Importing from glue.qglue is deprecated, use glue_qt.qglue instead', GlueDeprecationWarning)\n", - "/home/jon/opt/mambaforge/envs/glue-plotly/lib/python3.11/site-packages/glue/viewers/common/qt/__init__.py:3: GlueDeprecationWarning: Importing from glue.viewers.common.qt is deprecated, use glue_qt.viewers.common instead\n", - " warnings.warn('Importing from glue.viewers.common.qt is deprecated, use glue_qt.viewers.common instead', GlueDeprecationWarning)\n", - "/home/jon/opt/mambaforge/envs/glue-plotly/lib/python3.11/site-packages/glue/viewers/common/qt/data_viewer_with_state.py:3: GlueDeprecationWarning: Importing from glue.viewers.common.qt.data_viewer_with_state is deprecated, use glue_qt.viewers.common.data_viewer_with_state instead\n", - " warnings.warn('Importing from glue.viewers.common.qt.data_viewer_with_state is deprecated, use glue_qt.viewers.common.data_viewer_with_state instead', GlueDeprecationWarning)\n", - "/home/jon/opt/mambaforge/envs/glue-plotly/lib/python3.11/site-packages/glue/utils/qt/__init__.py:3: GlueDeprecationWarning: Importing from glue.utils.qt is deprecated, use glue_qt.utils instead\n", - " warnings.warn('Importing from glue.utils.qt is deprecated, use glue_qt.utils instead', GlueDeprecationWarning)\n", - "/home/jon/opt/mambaforge/envs/glue-plotly/lib/python3.11/site-packages/glue/viewers/common/qt/toolbar.py:3: GlueDeprecationWarning: Importing from glue.viewers.common.qt.toolbar is deprecated, use glue_qt.viewers.common.toolbar instead\n", - " warnings.warn('Importing from glue.viewers.common.qt.toolbar is deprecated, use glue_qt.viewers.common.toolbar instead', GlueDeprecationWarning)\n", - "/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", "dc = app.session.data_collection" ] }, + { + "cell_type": "markdown", + "id": "7d6adbc6-93b8-4a0e-8505-83ef23fb2f6b", + "metadata": {}, + "source": [ + "Create some random data to use, and do a bit of styling" + ] + }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "95d749da-73c8-432a-9a23-85d37e1b6fb5", "metadata": {}, "outputs": [], @@ -57,35 +69,84 @@ "x = [randint(0, 100) for _ in range(100)]\n", "y = [randint(300, 400) for _ in range(100)]\n", "data = Data(label='data', x=x, y=y)\n", - "dc.append(data)" + "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": [], + "source": [ + "x2 = [randint(0, 100) for _ in range(100)]\n", + "y2 = [randint(300, 400) for _ in range(100)]\n", + "data2 = Data(label='data2', x=x2, y=y2)\n", + "dc.append(data2)\n", + "app.add_link(data, 'x', data2, 'x')\n", + "app.add_link(data, 'y', data2, 'y')\n", + "data.style.color = \"#0000ff\"\n", + "data.style.markersize = 6" + ] + }, + { + "cell_type": "markdown", + "id": "2c520488-472c-4c43-8f29-3ae91fe41c13", + "metadata": {}, + "source": [ + "### Create a Plotly Scatter Viewer" + ] + }, + { + "cell_type": "code", + "execution_count": null, "id": "cf42768e-6d31-4375-90ee-facd8d19800a", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "d16a74d4189f4da0b614362141eb7dcb", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "LayoutWidget(controls={'toolbar_selection_tools': BasicJupyterToolbar(template=Template(template='