Plotly widget for trame
===========================================================================
.. image:: https://github.com/Kitware/trame-plotly/actions/workflows/test_and_release.yml/badge.svg
:target: https://github.com/Kitware/trame-plotly/actions/workflows/test_and_release.yml
:alt: Test and Release
trame-plotly extend trame **widgets** with components that can interface with Plotly to display their charts.
Plotly integration in trame allow you to create rich visualization by leveraging their `Python <https://plotly.com/python/>`_ or `JavaScript <https://plotly.com/javascript/>`_ interface.
The JavaScript version is exposed via `Vue.plotly <https://david-desmaisons.github.io/vue-plotly/>`_ within trame.widgets.plotly.Plotly class definition.
This package is not supposed to be used by itself but rather should come as a dependency of **trame**.
For any specificity, please refer to `the trame documentation <https://kitware.github.io/trame/>`_.
Installing
-----------------------------------------------------------
trame-plotly can be installed with `pip <https://pypi.org/project/trame-plotly/>`_:
.. code-block:: bash
pip install --upgrade trame-plotly
Usage
-----------------------------------------------------------
The `Trame Tutorial <https://kitware.github.io/trame/docs/tutorial.html>`_ is the place to go to learn how to use the library and start building your own application.
The `API Reference <https://trame.readthedocs.io/en/latest/index.html>`_ documentation provides API-level documentation.
The Plotly component relies on the server for generating the chart definition. This can be achieved by hand or by simply using the Python version of Plotly.
How to use it?
```````````````````````````````````````````````````````````
Using the Python library
.. code-block:: python
import plotly.graph_objects as go
from trame.widgets import plotly
fig = go.Figure(
data=go.Contour(
z=[
[10, 10.625, 12.5, 15.625, 20],
[5.625, 6.25, 8.125, 11.25, 15.625],
[2.5, 3.125, 5.0, 8.125, 12.5],
[0.625, 1.25, 3.125, 6.25, 10.625],
[0, 0.625, 2.5, 5.625, 10],
]
)
)
fig2 = go.Figure(
data=go.Contour(
z=[
[5.625, 6.25, 8.125, 11.25, 15.625],
[2.5, 3.125, 5.0, 8.125, 12.5],
[10, 10.625, 12.5, 15.625, 20],
[0.625, 1.25, 3.125, 6.25, 10.625],
[0, 0.625, 2.5, 5.625, 10],
]
)
)
widget = plotly.Figure(fig)
widget.update(fig2)
But if you are feeling more adventurous you can use the component API directly by building the data yourself as well.
.. code-block:: python
from trame.widgets import plotly
# https://plotly.com/javascript/reference/
plotly_data = [
{
"x": [1,2,3,4],
"y": [10,15,13,17],
"type": "scatter",
}
]
# https://plotly.com/javascript/reference/layout/
plotly_layout = {
"title": "My graph",
}
# https://plotly.com/javascript/configuration-options/
plotly_options = {
"scroll_zoom": True,
"editable": True,
"static_plot": True,
"to_image_options": {
"format": "svg", # one of png, svg, jpeg, webp
"filename": "custom_image",
"height": 500,
"width": 700,
"scale": 1 # Multiply title/legend/axis/canvas sizes by this factor
},
"display_mode_bar": True,
"mode_bar_buttons_to_remove": [
"zoom2d", "pan2d", "select2d", "lasso2d", "zoomIn2d", "zoomOut2d", "autoScale2d", "resetScale2d", # 2D
"zoom3d", "pan3d", "orbitRotation", "tableRotation", "handleDrag3d", "resetCameraDefault3d", "resetCameraLastSave3d", "hoverClosest3d", # 3D
"hoverClosestCartesian", "hoverCompareCartesian", # Cartesian
"zoomInGeo", "zoomOutGeo", "resetGeo", "hoverClosestGeo", # Geo
"hoverClosestGl2d", "hoverClosestPie", "toggleHover", "resetViews", "toImage", "sendDataToCloud", "toggleSpikelines", "resetViewMapbox", # Other
],
"mode_bar_buttons_to_add": [
{
"name": 'color toggler',
"icon": icon1, # https://plotly.com/javascript/configuration-options/#add-buttons-to-modebar
"click": "...",
},
],
"locale": "fr",
"display_logo": False,
"responsive": True,
"double_click_delay": 1000,
}
# Hand made chart
chart = plotly.Figure(
data=("chart_data", plotly_data),
layout=("chart_layout", plotly_layout),
**plotly_options,
)
.. list-table::
:widths: 20 80
:header-rows: 1
* - Type
- Values
* - properties
- data, layout, display_mode_bar, scroll_zoom, editable, static_plot, to_image_options, mode_bar_buttons_to_remove, mode_bar_buttons_to_add, locale, display_logo, responsive, double_click_delay
* - events
- after_export, after_plot, animated, animating_frame, animation_interrupted, auto_size, before_export, button_clicked, click, click_annotation, deselect, double_click, framework, hover, legend_click, legend_double_click, relayout, restyle, redraw, selected, selecting, slider_change, slider_end, slider_start, transitioning, transition_interrupted, unhover
License
-----------------------------------------------------------
trame-plotly is made available under the MIT License. For more details, see `LICENSE <https://github.com/Kitware/trame-plotly/blob/master/LICENSE>`_
This license has been chosen to match the one use by `Plotly <https://github.com/plotly/plotly.py/blob/master/LICENSE.txt>`_ and `vue-plotly <https://github.com/David-Desmaisons/vue-plotly/blob/master/LICENSE>`_ which are instrumental for making that library possible.
Community
-----------------------------------------------------------
`Trame <https://kitware.github.io/trame/>`_ | `Discussions <https://github.com/Kitware/trame/discussions>`_ | `Issues <https://github.com/Kitware/trame/issues>`_ | `RoadMap <https://github.com/Kitware/trame/projects/1>`_ | `Contact Us <https://www.kitware.com/contact-us/>`_
.. image:: https://zenodo.org/badge/410108340.svg
:target: https://zenodo.org/badge/latestdoi/410108340
Enjoying trame?
-----------------------------------------------------------
Share your experience `with a testimonial <https://github.com/Kitware/trame/issues/18>`_ or `with a brand approval <https://github.com/Kitware/trame/issues/19>`_.
Raw data
{
"_id": null,
"home_page": "",
"name": "trame-plotly",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Python,Interactive,Web,Application,Framework",
"author": "Kitware Inc.",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/6d/4d/abece97dd4cbe51912d312aceebf772e5c6050b594f75c0bc222c51e12b2/trame-plotly-3.0.2.tar.gz",
"platform": null,
"description": "Plotly widget for trame\n===========================================================================\n\n.. image:: https://github.com/Kitware/trame-plotly/actions/workflows/test_and_release.yml/badge.svg\n :target: https://github.com/Kitware/trame-plotly/actions/workflows/test_and_release.yml\n :alt: Test and Release\n\ntrame-plotly extend trame **widgets** with components that can interface with Plotly to display their charts.\n\nPlotly integration in trame allow you to create rich visualization by leveraging their `Python <https://plotly.com/python/>`_ or `JavaScript <https://plotly.com/javascript/>`_ interface.\nThe JavaScript version is exposed via `Vue.plotly <https://david-desmaisons.github.io/vue-plotly/>`_ within trame.widgets.plotly.Plotly class definition.\n\nThis package is not supposed to be used by itself but rather should come as a dependency of **trame**.\nFor any specificity, please refer to `the trame documentation <https://kitware.github.io/trame/>`_.\n\n\nInstalling\n-----------------------------------------------------------\n\ntrame-plotly can be installed with `pip <https://pypi.org/project/trame-plotly/>`_:\n\n.. code-block:: bash\n\n pip install --upgrade trame-plotly\n\nUsage\n-----------------------------------------------------------\n\nThe `Trame Tutorial <https://kitware.github.io/trame/docs/tutorial.html>`_ is the place to go to learn how to use the library and start building your own application.\n\nThe `API Reference <https://trame.readthedocs.io/en/latest/index.html>`_ documentation provides API-level documentation.\n\nThe Plotly component relies on the server for generating the chart definition. This can be achieved by hand or by simply using the Python version of Plotly.\n\n\nHow to use it?\n```````````````````````````````````````````````````````````\n\nUsing the Python library\n\n.. code-block:: python\n\n import plotly.graph_objects as go\n from trame.widgets import plotly\n\n fig = go.Figure(\n data=go.Contour(\n z=[\n [10, 10.625, 12.5, 15.625, 20],\n [5.625, 6.25, 8.125, 11.25, 15.625],\n [2.5, 3.125, 5.0, 8.125, 12.5],\n [0.625, 1.25, 3.125, 6.25, 10.625],\n [0, 0.625, 2.5, 5.625, 10],\n ]\n )\n )\n fig2 = go.Figure(\n data=go.Contour(\n z=[\n [5.625, 6.25, 8.125, 11.25, 15.625],\n [2.5, 3.125, 5.0, 8.125, 12.5],\n [10, 10.625, 12.5, 15.625, 20],\n [0.625, 1.25, 3.125, 6.25, 10.625],\n [0, 0.625, 2.5, 5.625, 10],\n ]\n )\n )\n\n widget = plotly.Figure(fig)\n widget.update(fig2)\n\nBut if you are feeling more adventurous you can use the component API directly by building the data yourself as well.\n\n.. code-block:: python\n\n from trame.widgets import plotly\n\n # https://plotly.com/javascript/reference/\n plotly_data = [\n {\n \"x\": [1,2,3,4],\n \"y\": [10,15,13,17],\n \"type\": \"scatter\",\n }\n ]\n\n # https://plotly.com/javascript/reference/layout/\n plotly_layout = {\n \"title\": \"My graph\",\n }\n\n # https://plotly.com/javascript/configuration-options/\n plotly_options = {\n \"scroll_zoom\": True,\n \"editable\": True,\n \"static_plot\": True,\n \"to_image_options\": {\n \"format\": \"svg\", # one of png, svg, jpeg, webp\n \"filename\": \"custom_image\",\n \"height\": 500,\n \"width\": 700,\n \"scale\": 1 # Multiply title/legend/axis/canvas sizes by this factor\n },\n \"display_mode_bar\": True,\n \"mode_bar_buttons_to_remove\": [\n \"zoom2d\", \"pan2d\", \"select2d\", \"lasso2d\", \"zoomIn2d\", \"zoomOut2d\", \"autoScale2d\", \"resetScale2d\", # 2D\n \"zoom3d\", \"pan3d\", \"orbitRotation\", \"tableRotation\", \"handleDrag3d\", \"resetCameraDefault3d\", \"resetCameraLastSave3d\", \"hoverClosest3d\", # 3D\n \"hoverClosestCartesian\", \"hoverCompareCartesian\", # Cartesian\n \"zoomInGeo\", \"zoomOutGeo\", \"resetGeo\", \"hoverClosestGeo\", # Geo\n \"hoverClosestGl2d\", \"hoverClosestPie\", \"toggleHover\", \"resetViews\", \"toImage\", \"sendDataToCloud\", \"toggleSpikelines\", \"resetViewMapbox\", # Other\n ],\n \"mode_bar_buttons_to_add\": [\n {\n \"name\": 'color toggler',\n \"icon\": icon1, # https://plotly.com/javascript/configuration-options/#add-buttons-to-modebar\n \"click\": \"...\",\n },\n ],\n \"locale\": \"fr\",\n \"display_logo\": False,\n \"responsive\": True,\n \"double_click_delay\": 1000,\n }\n\n # Hand made chart\n chart = plotly.Figure(\n data=(\"chart_data\", plotly_data),\n layout=(\"chart_layout\", plotly_layout),\n **plotly_options,\n )\n\n\n.. list-table::\n :widths: 20 80\n :header-rows: 1\n\n * - Type\n - Values\n * - properties\n - data, layout, display_mode_bar, scroll_zoom, editable, static_plot, to_image_options, mode_bar_buttons_to_remove, mode_bar_buttons_to_add, locale, display_logo, responsive, double_click_delay\n * - events\n - after_export, after_plot, animated, animating_frame, animation_interrupted, auto_size, before_export, button_clicked, click, click_annotation, deselect, double_click, framework, hover, legend_click, legend_double_click, relayout, restyle, redraw, selected, selecting, slider_change, slider_end, slider_start, transitioning, transition_interrupted, unhover\n\n\nLicense\n-----------------------------------------------------------\n\ntrame-plotly is made available under the MIT License. For more details, see `LICENSE <https://github.com/Kitware/trame-plotly/blob/master/LICENSE>`_\nThis license has been chosen to match the one use by `Plotly <https://github.com/plotly/plotly.py/blob/master/LICENSE.txt>`_ and `vue-plotly <https://github.com/David-Desmaisons/vue-plotly/blob/master/LICENSE>`_ which are instrumental for making that library possible.\n\n\nCommunity\n-----------------------------------------------------------\n\n`Trame <https://kitware.github.io/trame/>`_ | `Discussions <https://github.com/Kitware/trame/discussions>`_ | `Issues <https://github.com/Kitware/trame/issues>`_ | `RoadMap <https://github.com/Kitware/trame/projects/1>`_ | `Contact Us <https://www.kitware.com/contact-us/>`_\n\n.. image:: https://zenodo.org/badge/410108340.svg\n :target: https://zenodo.org/badge/latestdoi/410108340\n\n\nEnjoying trame?\n-----------------------------------------------------------\n\nShare your experience `with a testimonial <https://github.com/Kitware/trame/issues/18>`_ or `with a brand approval <https://github.com/Kitware/trame/issues/19>`_.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Plotly figure widget for trame",
"version": "3.0.2",
"project_urls": null,
"split_keywords": [
"python",
"interactive",
"web",
"application",
"framework"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b6decac286616563d588e7c7d9a90f9800297cf6a231ed72249de469e61246d3",
"md5": "b09a7072ea20b3a2b986c34108db6387",
"sha256": "eff0f0259c6dce035745535a6e79a4b64f0ef5c32df3d826307ed691d6838902"
},
"downloads": -1,
"filename": "trame_plotly-3.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b09a7072ea20b3a2b986c34108db6387",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 3127751,
"upload_time": "2023-09-15T19:59:02",
"upload_time_iso_8601": "2023-09-15T19:59:02.390562Z",
"url": "https://files.pythonhosted.org/packages/b6/de/cac286616563d588e7c7d9a90f9800297cf6a231ed72249de469e61246d3/trame_plotly-3.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6d4dabece97dd4cbe51912d312aceebf772e5c6050b594f75c0bc222c51e12b2",
"md5": "d0247acef806d2c6b2b310ae091a8b84",
"sha256": "bb472ace64c9c2e65bb7c535c0567a35bfc3711588759731c36b2d7f6e3434b9"
},
"downloads": -1,
"filename": "trame-plotly-3.0.2.tar.gz",
"has_sig": false,
"md5_digest": "d0247acef806d2c6b2b310ae091a8b84",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3074138,
"upload_time": "2023-09-15T19:59:04",
"upload_time_iso_8601": "2023-09-15T19:59:04.433292Z",
"url": "https://files.pythonhosted.org/packages/6d/4d/abece97dd4cbe51912d312aceebf772e5c6050b594f75c0bc222c51e12b2/trame-plotly-3.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-15 19:59:04",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "trame-plotly"
}