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='\\n…"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
- "viewer = app.new_data_viewer(PlotlyScatterView, data=data)\n",
- "layer = viewer.layers[0]\n",
- "layer.state.color = \"#ff0000\"\n",
- "layer.state.size = 4"
+ "scatter_viewer = app.new_data_viewer(\"plotly_scatter\", data=data)\n",
+ "# Alternatively, you can use the viewer class:\n",
+ "# viewer = app.new_data_viewer(PlotlyScatterView, data=data)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "cbeeb763-daf0-4828-8535-f05f97ec856f",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "scatter_viewer.add_data(data2)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "1355c76d-ad3d-4202-a08f-ee17b1facbd4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "scatter_viewer.layers"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "143236d3-446b-4286-b24c-a9511204b970",
+ "metadata": {},
+ "source": [
+ "### Create a Plotly Histogram Viewer"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "da0a70ee-f299-47cd-9eb0-9a634d983c02",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "scatter_viewer.layers[1].state.zorder"
]
},
{
@@ -95,418 +156,49 @@
"metadata": {},
"outputs": [],
"source": [
- "viewer = app.new_data_viewer(PlotlyHistogramView, data=data)\n",
- "layer = viewer.layers[0]"
+ "histogram_viewer = app.new_data_viewer(\"plotly_histogram\", data=data)\n",
+ "# Alternatively, you can use the viewer class:\n",
+ "# viewer = app.new_data_viewer(PlotlyHistogramView, data=data)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "588347a7-8f4d-4f47-9838-a4a2e4106b02",
+ "metadata": {},
+ "source": [
+ "### Dotplot Viewer\n",
+ "`glue-plotly` provides an alternate layer artist for the histogram viewer that displays data as a dotplot. While we don't offer a built-in viewer that uses this functionality, you can use the simple implementation below as a starting point if you're interested in using dotplots."
]
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": null,
"id": "4f9d9ffe-ec2e-4d7f-aa8b-8b2a7524b9c2",
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "['__annotations__',\n",
- " '__class__',\n",
- " '__contains__',\n",
- " '__del__',\n",
- " '__delattr__',\n",
- " '__dict__',\n",
- " '__dir__',\n",
- " '__doc__',\n",
- " '__eq__',\n",
- " '__format__',\n",
- " '__ge__',\n",
- " '__getattribute__',\n",
- " '__getitem__',\n",
- " '__getstate__',\n",
- " '__gt__',\n",
- " '__hash__',\n",
- " '__init__',\n",
- " '__init_subclass__',\n",
- " '__iter__',\n",
- " '__le__',\n",
- " '__lt__',\n",
- " '__module__',\n",
- " '__ne__',\n",
- " '__new__',\n",
- " '__reduce__',\n",
- " '__reduce_ex__',\n",
- " '__repr__',\n",
- " '__setattr__',\n",
- " '__setitem__',\n",
- " '__setstate__',\n",
- " '__sizeof__',\n",
- " '__str__',\n",
- " '__subclasshook__',\n",
- " '__weakref__',\n",
- " '_active_widgets',\n",
- " '_add_annotation_like',\n",
- " '_add_notifiers',\n",
- " '_all_trait_default_generators',\n",
- " '_allow_disable_validation',\n",
- " '_animation_duration_validator',\n",
- " '_animation_easing_validator',\n",
- " '_batch_layout_edits',\n",
- " '_batch_trace_edits',\n",
- " '_bracket_re',\n",
- " '_build_dispatch_plan',\n",
- " '_build_update_params_from_batch',\n",
- " '_call_widget_constructed',\n",
- " '_comm_changed',\n",
- " '_compare',\n",
- " '_config',\n",
- " '_control_comm',\n",
- " '_cross_validation_lock',\n",
- " '_data',\n",
- " '_data_defaults',\n",
- " '_data_objs',\n",
- " '_data_validator',\n",
- " '_default_keys',\n",
- " '_descriptors',\n",
- " '_dispatch_layout_change_callbacks',\n",
- " '_dispatch_trace_change_callbacks',\n",
- " '_display_frames_error',\n",
- " '_dom_classes',\n",
- " '_filter_by_selector',\n",
- " '_frame_objs',\n",
- " '_frames_validator',\n",
- " '_gen_repr_from_keys',\n",
- " '_get_child_prop_defaults',\n",
- " '_get_child_props',\n",
- " '_get_embed_state',\n",
- " '_get_subplot_coordinates',\n",
- " '_get_subplot_rows_columns',\n",
- " '_get_trait_default_generator',\n",
- " '_grid_ref',\n",
- " '_grid_str',\n",
- " '_handle_control_comm_msg',\n",
- " '_handle_custom_msg',\n",
- " '_handle_msg',\n",
- " '_handler_js2py_layoutDelta',\n",
- " '_handler_js2py_pointsCallback',\n",
- " '_handler_js2py_relayout',\n",
- " '_handler_js2py_restyle',\n",
- " '_handler_js2py_traceDeltas',\n",
- " '_handler_js2py_update',\n",
- " '_has_subplots',\n",
- " '_holding_sync',\n",
- " '_in_batch_mode',\n",
- " '_index_is',\n",
- " '_init_child_props',\n",
- " '_initialize_layout_template',\n",
- " '_instance_inits',\n",
- " '_ipython_display_',\n",
- " '_is_dict_list',\n",
- " '_is_key_path_compatible',\n",
- " '_is_numpy',\n",
- " '_js2py_layoutDelta',\n",
- " '_js2py_pointsCallback',\n",
- " '_js2py_relayout',\n",
- " '_js2py_restyle',\n",
- " '_js2py_traceDeltas',\n",
- " '_js2py_update',\n",
- " '_last_layout_edit_id',\n",
- " '_last_trace_edit_id',\n",
- " '_layout',\n",
- " '_layout_defaults',\n",
- " '_layout_edit_in_process',\n",
- " '_layout_obj',\n",
- " '_layout_validator',\n",
- " '_lock_property',\n",
- " '_log_default',\n",
- " '_make_axis_spanning_layout_object',\n",
- " '_model_id',\n",
- " '_model_module',\n",
- " '_model_module_version',\n",
- " '_model_name',\n",
- " '_msg_callbacks',\n",
- " '_normalize_trace_indexes',\n",
- " '_notify_observers',\n",
- " '_notify_trait',\n",
- " '_perform_batch_animate',\n",
- " '_perform_plotly_relayout',\n",
- " '_perform_plotly_restyle',\n",
- " '_perform_plotly_update',\n",
- " '_perform_select_traces',\n",
- " '_perform_update',\n",
- " '_process_multiple_axis_spanning_shapes',\n",
- " '_property_lock',\n",
- " '_py2js_addTraces',\n",
- " '_py2js_animate',\n",
- " '_py2js_deleteTraces',\n",
- " '_py2js_moveTraces',\n",
- " '_py2js_relayout',\n",
- " '_py2js_removeLayoutProps',\n",
- " '_py2js_removeTraceProps',\n",
- " '_py2js_restyle',\n",
- " '_py2js_update',\n",
- " '_raise_invalid_rows_cols',\n",
- " '_register_validator',\n",
- " '_relayout_child',\n",
- " '_remove_notifiers',\n",
- " '_remove_overlapping_props',\n",
- " '_repr_html_',\n",
- " '_repr_keys',\n",
- " '_repr_mimebundle_',\n",
- " '_restyle_child',\n",
- " '_select_annotations_like',\n",
- " '_select_layout_subplots_by_prefix',\n",
- " '_select_subplot_coordinates',\n",
- " '_selector_matches',\n",
- " '_send',\n",
- " '_send_addTraces_msg',\n",
- " '_send_animate_msg',\n",
- " '_send_deleteTraces_msg',\n",
- " '_send_moveTraces_msg',\n",
- " '_send_relayout_msg',\n",
- " '_send_restyle_msg',\n",
- " '_send_update_msg',\n",
- " '_set_in',\n",
- " '_set_trace_grid_position',\n",
- " '_set_trace_uid',\n",
- " '_should_send_property',\n",
- " '_states_to_send',\n",
- " '_static_immutable_initial_values',\n",
- " '_str_to_dict_path',\n",
- " '_subplot_not_empty',\n",
- " '_to_ordered_dict',\n",
- " '_trace_edit_in_process',\n",
- " '_trait_default_generators',\n",
- " '_trait_from_json',\n",
- " '_trait_notifiers',\n",
- " '_trait_to_json',\n",
- " '_trait_validators',\n",
- " '_trait_values',\n",
- " '_traits',\n",
- " '_transform_data',\n",
- " '_valid_underscore_properties',\n",
- " '_validate',\n",
- " '_validate_get_grid_ref',\n",
- " '_validate_rows_cols',\n",
- " '_view_count',\n",
- " '_view_module',\n",
- " '_view_module_version',\n",
- " '_view_name',\n",
- " '_waiting_edit_callbacks',\n",
- " '_widget_construction_callback',\n",
- " '_widget_types',\n",
- " 'add_annotation',\n",
- " 'add_bar',\n",
- " 'add_barpolar',\n",
- " 'add_box',\n",
- " 'add_candlestick',\n",
- " 'add_carpet',\n",
- " 'add_choropleth',\n",
- " 'add_choroplethmapbox',\n",
- " 'add_class',\n",
- " 'add_cone',\n",
- " 'add_contour',\n",
- " 'add_contourcarpet',\n",
- " 'add_densitymapbox',\n",
- " 'add_funnel',\n",
- " 'add_funnelarea',\n",
- " 'add_heatmap',\n",
- " 'add_heatmapgl',\n",
- " 'add_histogram',\n",
- " 'add_histogram2d',\n",
- " 'add_histogram2dcontour',\n",
- " 'add_hline',\n",
- " 'add_hrect',\n",
- " 'add_icicle',\n",
- " 'add_image',\n",
- " 'add_indicator',\n",
- " 'add_isosurface',\n",
- " 'add_layout_image',\n",
- " 'add_mesh3d',\n",
- " 'add_ohlc',\n",
- " 'add_parcats',\n",
- " 'add_parcoords',\n",
- " 'add_pie',\n",
- " 'add_pointcloud',\n",
- " 'add_sankey',\n",
- " 'add_scatter',\n",
- " 'add_scatter3d',\n",
- " 'add_scattercarpet',\n",
- " 'add_scattergeo',\n",
- " 'add_scattergl',\n",
- " 'add_scattermapbox',\n",
- " 'add_scatterpolar',\n",
- " 'add_scatterpolargl',\n",
- " 'add_scattersmith',\n",
- " 'add_scatterternary',\n",
- " 'add_selection',\n",
- " 'add_shape',\n",
- " 'add_splom',\n",
- " 'add_streamtube',\n",
- " 'add_sunburst',\n",
- " 'add_surface',\n",
- " 'add_table',\n",
- " 'add_trace',\n",
- " 'add_traces',\n",
- " 'add_traits',\n",
- " 'add_treemap',\n",
- " 'add_violin',\n",
- " 'add_vline',\n",
- " 'add_volume',\n",
- " 'add_vrect',\n",
- " 'add_waterfall',\n",
- " 'append_trace',\n",
- " 'batch_animate',\n",
- " 'batch_update',\n",
- " 'blur',\n",
- " 'class_own_trait_events',\n",
- " 'class_own_traits',\n",
- " 'class_trait_names',\n",
- " 'class_traits',\n",
- " 'close',\n",
- " 'close_all',\n",
- " 'comm',\n",
- " 'cross_validation_lock',\n",
- " 'data',\n",
- " 'focus',\n",
- " 'for_each_annotation',\n",
- " 'for_each_coloraxis',\n",
- " 'for_each_geo',\n",
- " 'for_each_layout_image',\n",
- " 'for_each_legend',\n",
- " 'for_each_mapbox',\n",
- " 'for_each_polar',\n",
- " 'for_each_scene',\n",
- " 'for_each_selection',\n",
- " 'for_each_shape',\n",
- " 'for_each_smith',\n",
- " 'for_each_ternary',\n",
- " 'for_each_trace',\n",
- " 'for_each_xaxis',\n",
- " 'for_each_yaxis',\n",
- " 'frames',\n",
- " 'full_figure_for_development',\n",
- " 'get_manager_state',\n",
- " 'get_state',\n",
- " 'get_subplot',\n",
- " 'get_view_spec',\n",
- " 'handle_comm_opened',\n",
- " 'handle_control_comm_opened',\n",
- " 'has_trait',\n",
- " 'hold_sync',\n",
- " 'hold_trait_notifications',\n",
- " 'keys',\n",
- " 'layout',\n",
- " 'log',\n",
- " 'model_id',\n",
- " 'notify_change',\n",
- " 'observe',\n",
- " 'on_edits_completed',\n",
- " 'on_msg',\n",
- " 'on_trait_change',\n",
- " 'on_widget_constructed',\n",
- " 'open',\n",
- " 'plotly_relayout',\n",
- " 'plotly_restyle',\n",
- " 'plotly_update',\n",
- " 'pop',\n",
- " 'print_grid',\n",
- " 'remove_class',\n",
- " 'select_annotations',\n",
- " 'select_coloraxes',\n",
- " 'select_geos',\n",
- " 'select_layout_images',\n",
- " 'select_legends',\n",
- " 'select_mapboxes',\n",
- " 'select_polars',\n",
- " 'select_scenes',\n",
- " 'select_selections',\n",
- " 'select_shapes',\n",
- " 'select_smiths',\n",
- " 'select_ternaries',\n",
- " 'select_traces',\n",
- " 'select_xaxes',\n",
- " 'select_yaxes',\n",
- " 'send',\n",
- " 'send_state',\n",
- " 'set_state',\n",
- " 'set_subplots',\n",
- " 'set_trait',\n",
- " 'setup_instance',\n",
- " 'show',\n",
- " 'tabbable',\n",
- " 'to_dict',\n",
- " 'to_html',\n",
- " 'to_image',\n",
- " 'to_json',\n",
- " 'to_ordered_dict',\n",
- " 'to_plotly_json',\n",
- " 'tooltip',\n",
- " 'trait_defaults',\n",
- " 'trait_events',\n",
- " 'trait_has_value',\n",
- " 'trait_metadata',\n",
- " 'trait_names',\n",
- " 'trait_values',\n",
- " 'traits',\n",
- " 'unobserve',\n",
- " 'unobserve_all',\n",
- " 'update',\n",
- " 'update_annotations',\n",
- " 'update_coloraxes',\n",
- " 'update_geos',\n",
- " 'update_layout',\n",
- " 'update_layout_images',\n",
- " 'update_legends',\n",
- " 'update_mapboxes',\n",
- " 'update_polars',\n",
- " 'update_scenes',\n",
- " 'update_selections',\n",
- " 'update_shapes',\n",
- " 'update_smiths',\n",
- " 'update_ternaries',\n",
- " 'update_traces',\n",
- " 'update_xaxes',\n",
- " 'update_yaxes',\n",
- " 'widget_types',\n",
- " 'widgets',\n",
- " 'write_html',\n",
- " 'write_image',\n",
- " 'write_json']"
- ]
- },
- "execution_count": 7,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
- "dir(viewer.figure_widget)"
+ "from glue_plotly.viewers.histogram.dotplot_layer_artist import PlotlyDotplotLayerArtist\n",
+ "\n",
+ "class DotplotViewer(PlotlyHistogramView):\n",
+ "\n",
+ " _data_artist_cls = PlotlyDotplotLayerArtist\n",
+ " _subset_artist_cls = PlotlyDotplotLayerArtist"
]
},
{
"cell_type": "code",
- "execution_count": 10,
- "id": "5012f018-8871-4e82-9f16-aa5a6a5ef836",
+ "execution_count": null,
+ "id": "174cd945-0744-43dc-b23e-bcef244a0bff",
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "plotly.graph_objs._figurewidget.FigureWidget"
- ]
- },
- "execution_count": 10,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
- "type(viewer.figure_widget)"
+ "dotplot_viewer = app.new_data_viewer(DotplotViewer, data=data)"
]
},
{
"cell_type": "code",
"execution_count": null,
- "id": "d3aaa886-491b-4da9-bfbb-78befbd504ba",
+ "id": "26492697-440b-4df0-9624-a6cd3637f1cb",
"metadata": {},
"outputs": [],
"source": []
@@ -528,7 +220,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.4"
+ "version": "3.12.1"
}
},
"nbformat": 4,