{"id":22546554,"url":"https://github.com/deephaven/deephaven-plugin-matplotlib","last_synced_at":"2025-04-10T00:52:17.833Z","repository":{"id":44880109,"uuid":"442791971","full_name":"deephaven/deephaven-plugin-matplotlib","owner":"deephaven","description":"Deephaven Plugin for matplotlib","archived":false,"fork":false,"pushed_at":"2023-09-13T14:07:53.000Z","size":31,"stargazers_count":3,"open_issues_count":0,"forks_count":5,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-10T00:52:11.426Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deephaven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-29T14:07:14.000Z","updated_at":"2022-11-22T14:44:46.000Z","dependencies_parsed_at":"2023-02-09T05:01:07.267Z","dependency_job_id":null,"html_url":"https://github.com/deephaven/deephaven-plugin-matplotlib","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deephaven%2Fdeephaven-plugin-matplotlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deephaven%2Fdeephaven-plugin-matplotlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deephaven%2Fdeephaven-plugin-matplotlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deephaven%2Fdeephaven-plugin-matplotlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deephaven","download_url":"https://codeload.github.com/deephaven/deephaven-plugin-matplotlib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137996,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-07T15:08:12.328Z","updated_at":"2025-04-10T00:52:17.815Z","avatar_url":"https://github.com/deephaven.png","language":"Python","readme":"# DEPRECATED\n\nPlease use the monorepo at https://github.com/deephaven/deephaven-plugins\n\nThe Deephaven Plugin for matplotlib. Allows for opening matplotlib plots in a Deephaven environment. Any matplotlib plot\nshould be viewable by default. For example:\n```python\nimport matplotlib.pyplot as plt\nfig = plt.figure()\nax = fig.subplots()  # Create a figure containing a single axes.\nax.plot([1, 2, 3, 4], [4, 2, 6, 7])  # Plot some data on the axes.\n```\nYou can also use `TableAnimation`, which allows updating a plot whenever a Deephaven Table is updated.\n\n## `TableAnimation` Usage\n\n`TableAnimation` is a matplotlib `Animation` that is driven by updates in a Deephaven Table. Every time the table that\nis being listened to updates, the provided function will run again.\n\n### Line Plot\n```python\nimport matplotlib.pyplot as plt\nfrom deephaven import time_table\nfrom deephaven.plugin.matplotlib import TableAnimation\n\n# Create a ticking table with the sin function\ntt = time_table(\"00:00:01\").update([\"x=i\", \"y=Math.sin(x)\"])\n\nfig = plt.figure()      # Create a new figure\nax = fig.subplots()     # Add an axes to the figure\nline, = ax.plot([],[])  # Plot a line. Start with empty data, will get updated with table updates.\n\n# Define our update function. We only look at `data` here as the data is already stored in the format we want\ndef update_fig(data, update):\n    line.set_data([data['x'], data['y']])\n    \n    # Resize and scale the axes. Our data may have expanded and we don't want it to appear off screen.\n    ax.relim()\n    ax.autoscale_view(True, True, True)\n\n# Create our animation. It will listen for updates on `tt` and call `update_fig` whenever there is an update\nani = TableAnimation(fig, tt, update_fig)\n```\n\n### Scatter Plot\nScatter plots require data in a different format that Line plots, so need to pass in the data differently.\n```python\nimport matplotlib.pyplot as plt\nfrom deephaven import time_table\nfrom deephaven.plugin.matplotlib import TableAnimation\n\ntt = time_table(\"00:00:01\").update([\"x=Math.random()\", \"y=Math.random()\", \"z=Math.random()*50\"])\n\nfig = plt.figure()\nax = fig.subplots()\nax.set_xlim(0, 1)\nax.set_ylim(0, 1)\nscat = ax.scatter([],[])    # Provide empty data initially\nscatter_offsets = []        # Store separate arrays for offsets and sizes\nscatter_sizes = []\n\ndef update_fig(data, update):\n    # This assumes that table is always increasing. Otherwise need to look at other \n    # properties in update for creates and removed items\n    added = update.added()\n    for i in range(0, len(added['x'])):\n        # Append new data to the sources\n        scatter_offsets.append([added['x'][i], added['y'][i]])\n        scatter_sizes.append(added['z'][i])\n\n    # Update the figure\n    scat.set_offsets(scatter_offsets)\n    scat.set_sizes(scatter_sizes)\n\nani = TableAnimation(fig, tt, update_fig)\n```\n\n### Multiple Series\nIt's possible to have multiple kinds of series in the same figure. Here is an example driving a line and a scatter plot:\n```python\nimport matplotlib.pyplot as plt\nfrom deephaven import time_table\nfrom deephaven.plugin.matplotlib import TableAnimation\n\ntt = time_table(\"00:00:01\").update([\"x=i\", \"y=Math.sin(x)\", \"z=Math.cos(x)\", \"r=Math.random()\", \"s=Math.random()*100\"])\n\nfig = plt.figure()\nax = fig.subplots()\nline1, = ax.plot([],[])\nline2, = ax.plot([],[])\nscat = ax.scatter([], [])\nscatter_offsets = []\nscatter_sizes = []\n\ndef update_fig(data, update):\n    line1.set_data([data['x'], data['y']])\n    line2.set_data([data['x'], data['z']])\n    added = update.added()\n    for i in range(0, len(added['x'])):\n        scatter_offsets.append([added['x'][i], added['r'][i]])\n        scatter_sizes.append(added['s'][i])\n    scat.set_offsets(scatter_offsets)\n    scat.set_sizes(scatter_sizes)\n    ax.relim()\n    ax.autoscale_view(True, True, True)\n\nani = TableAnimation(fig, tt, update_fig)\n```\n\n## Build\n\nTo create your build / development environment:\n\n```sh\npython -m venv .venv\nsource .venv/bin/activate\npip install --upgrade pip setuptools\npip install build deephaven-plugin matplotlib\n```\n\nTo build:\n\n```sh\npython -m build --wheel\n```\n\nThe wheel is stored in `dist/`. \n\nTo test within [deephaven-core](https://github.com/deephaven/deephaven-core), note where this wheel is stored (using `pwd`, for example).\nThen, follow the directions in the [deephaven-js-plugins](https://github.com/deephaven/deephaven-js-plugins) repo.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeephaven%2Fdeephaven-plugin-matplotlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeephaven%2Fdeephaven-plugin-matplotlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeephaven%2Fdeephaven-plugin-matplotlib/lists"}