René's URL Explorer Experiment


Title: New module proposal: plotly.io · Issue #1098 · plotly/plotly.py · GitHub

Open Graph Title: New module proposal: plotly.io · Issue #1098 · plotly/plotly.py

X Title: New module proposal: plotly.io · Issue #1098 · plotly/plotly.py

Description: Overview I propose that we introduce a new module, plotly.io, to house a new suite of functions related to the input and output of plotly figure objects. Why now? There are two immediate needs motivating this proposal. It's time to integ...

Open Graph Description: Overview I propose that we introduce a new module, plotly.io, to house a new suite of functions related to the input and output of plotly figure objects. Why now? There are two immediate needs moti...

X Description: Overview I propose that we introduce a new module, plotly.io, to house a new suite of functions related to the input and output of plotly figure objects. Why now? There are two immediate needs moti...

Opengraph URL: https://github.com/plotly/plotly.py/issues/1098

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"New module proposal: plotly.io","articleBody":"## Overview\r\nI propose that we introduce a new module, `plotly.io`, to house a new suite of functions related to the input and output of plotly figure objects.\r\n\r\n## Why now?\r\nThere are two immediate needs motivating this proposal.\r\n\r\n 1. It's time to integrate [orca](https://github.com/plotly/orca) for static image export\r\n 2. For integration with the JupyterLab [plotly-renderer](https://github.com/jupyterlab/jupyter-renderers/tree/master/packages/plotly-extension) and JupyterLab [chart editor](https://github.com/plotly/jupyterlab-chart-editor), we need a function to write out the JSON representation of a figure with the proper plotly metadata\r\n\r\n## How do things work now?\r\nHere's in inventory of some of our current methods that can perform I/O operations:\r\n - `plotly.plotly.plot`\r\n   - Save figure to plot.ly (with optional filename) and return URL\r\n   - Optionally open in browser\r\n - `plotly.offline.plot`\r\n   - Save html to a local file\r\n   - or return an HTML `div` string\r\n   - optionally open in browser \r\n - `plotly.image.save_as`\r\n   - Save image to a local file with specified image parameters by making a request to plot.ly\r\n - `plotly.get_figure`\r\n   - Convert plot.ly URL into a local figure object\r\n\r\n## Why add something new?\r\nBy my taste, these APIs are a bit scattered and not very discoverable by users without consulting external documentation.  It's also unclear (to me at least) where additional I/O methods, like to two listed above, should be added.\r\n\r\nThere are good reasons that we ended up where we are (e.g. there was no offline mode when the `plotly.plotly` module was developed), but I'd like to propose we adopt a new approach moving forward.\r\n\r\nThe goal is that the options for saving/loading/converting figures should consistent and easily discoverable without the need to consult external documentation.  By triggering tab-completion on the `plotly.io` module, users should be able to learn about all of the import/export options available to them.\r\n\r\n## Design\r\nI propose that the initial functions in the `plotly.io` module have one of 4 prefixes, followed by the format name:\r\n\r\n - `read_{format}(file, ...) -\u003e Figure`:  These methods all accept, as the first argument, either a string or a `read`-able file object. Strings are interpreted as local file paths, other objects are read from. These methods all return a `Figure` object.\r\n - `write_{format}(fig, file, ...) -\u003e None`: These methods all accept the `Figure` to be written as the first argument. The second argument is either a string or a `write`-able file object. Strings are interpreted as local file paths, other objects are written to. These methods `raise` on write failures and return `None`.\r\n - `from_{format}(data, ...) -\u003e Figure`: These methods all accept, as the first argument, some in-memory Python object and return a `Figure` object. These methods don't interact with the file system and have no side effects.\r\n - `to_{format}(fig, ...) -\u003e Any`: These methods all accept the `Figure` to be converted as the first argument. They return an in memory Python object corresponding to the format. These methods don't interact with the file system and have no side effects.\r\n\r\nThe ellipses (`...`) in the signatures above represent additional arguments/options that are specific to given format.\r\n\r\nIn addition to their presence as standalone functions in `plotly.io`, there would also be `write_{format}` and `to_{format}` methods on `Figure` objects. This way, people could use tab completion on a figure itself to learn how to save/convert it.\r\n\r\n## Examples\r\nHere are some examples of functions that could follow these conventions\r\n\r\n```python\r\nimport plotly.graph_objs as go\r\nimport plotly.io as plio\r\nfig = go.Figure(...)\r\n```\r\nSave to HTML file and embed plotly.js\r\n```python\r\nplio.write_html(fig, 'somewhere.html', include_plotlyjs=True)\r\n# or\r\nfig.write_html('somewhere.html', include_plotlyjs=True)\r\n```\r\nBuild an HTML `div` string for figure, and don't embed plotly.js\r\n```python\r\ndiv_str = plio.to_html(fig, output_type='div', include_plotlyjs=False)\r\n# or\r\ndiv_str = fig.to_html(output_type='div', include_plotlyjs=False)\r\n```\r\nSave figure to a file as an svg image of a specific size (using orca)\r\n```python\r\nplio.write_image(fig, 'somewhere.svg', format='svg', width=500, height=400)\r\n# or\r\nfig.write_image('somewhere.svg', format='svg', width=500, height=400)\r\n```\r\nBuild a bytes string representation of the Figure converted to a PNG image\r\n```python\r\npng_bytes = plio.to_image(fig, format='png')\r\n```\r\nBuild a `PIL` `Image` object representing the figure as a static image\r\n```python\r\npil_img = plio.to_pil(fig, format='png')\r\n```\r\nSave to json file\r\n```python\r\nplio.write_json(fig, 'fig.json')\r\n```\r\nSave as gzipped json file to an [HDFS filesystem using PyArrow](https://arrow.apache.org/docs/python/filesystems.html)\r\n```python\r\nimport pyarrow as pa\r\nfs = pa.hdfs.connect(host, port, user=user, ...)\r\nwith fs.open('/path/to/fig.json.gz', 'rb') as f:\r\n    plio.write_json(fig, f, compression='gzip')\r\n```\r\nConvert to json string\r\n```python\r\njson_str = plio.to_json(fig)\r\n```\r\nConvert figure to plot.ly url\r\n```python\r\nplot_ly_url = plio.to_plot_ly(fig)\r\n```\r\nGet figure from plot.ly url\r\n```python\r\nfig = plio.from_plot_ly(plot_ly_url)\r\n```\r\nConvert matplotlib/altair/holoviews/other object to plotly figure\r\n```python\r\nfig = plio.from_matplotlib(mpl_fig)\r\nfig = plio.from_holoviews(hv_obj)\r\nfig = plio.from_altair(altair_fig)\r\n```\r\n\r\n## What happens to `plot`?\r\nNothing, it works fine and there's no reason to change it. Some of these new methods could directly call the current plot methods, or we could look at refactoring the internals a bit so that both `plot` and `io` methods share most of their logic.\r\n\r\n## What about displaying plots?\r\nI don't intend for any of the `to_{format}`/`save_{format}` functions to display the figure.  So initially, the `plot` and `iplot` methods would continue to serve that purpose.\r\n\r\nOne option would be to eventually add a `plotly.io.show` method that is capable of displaying figures using different \"backends\" (similar in spirit to matplotlib).  We actually already have 5 backends for displaying figures:\r\n 1. plot.ly in browser (`plotly.plotly.plot`)\r\n 2. plot.ly in notebook iframe (`plotly.plotly.iplot`)\r\n 3. offline in browser (`plotly.offline.plot`)\r\n 4. offline in notebook (`plotly.offline.iplot`)\r\n 5. display as ipywidget (`plotly.graph_objs.FigureWidget`)\r\n\r\nOnce we have orca integrated, we could even add a static image backend if people were interested in that.\r\n\r\n## Milestone\r\nI propose adding the `plotly.io` module with support for json and orca-based image formats in version 3.2.0.  Depending on how much work it turns out to be, it would be nice to also populate the module with existing html and plot_ly support as well.\r\n\r\nPlease chime in if you have opinions on this!\r\n\r\ncc: @chriddyp @cldougl @Kully @nicolaskruchten @jackparmer @bcdunbar","author":{"url":"https://github.com/jonmmease","@type":"Person","name":"jonmmease"},"datePublished":"2018-08-07T16:20:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/1098/plotly.py/issues/1098"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:32e91d0f-212e-3430-f7c2-0be13b1cace9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9F72:9AF43:34D680:4C6B28:6A574782
html-safe-nonce318de6d3d8370937411e4a3c4c9473a03420e382160a3682a0c5e67a8b043440
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjcyOjlBRjQzOjM0RDY4MDo0QzZCMjg6NkE1NzQ3ODIiLCJ2aXNpdG9yX2lkIjoiMTYxNzM4MDI0OTAzMjkzNTI5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacad592f9a3f4b386756b162c1a4215df1d8d8ede1e484d320e6420a7eb678d03d
hovercard-subject-tagissue:348393685
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.py/1098/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b203777de04059b4a3b09b61d160d9949229f0d46bf417a4c30c48db0150cd07/plotly/plotly.py/issues/1098
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b203777de04059b4a3b09b61d160d9949229f0d46bf417a4c30c48db0150cd07/plotly/plotly.py/issues/1098
og:image:altOverview I propose that we introduce a new module, plotly.io, to house a new suite of functions related to the input and output of plotly figure objects. Why now? There are two immediate needs moti...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejonmmease
hostnamegithub.com
expected-hostnamegithub.com
None4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98
turbo-cache-controlno-preview
go-importgithub.com/plotly/plotly.py git https://github.com/plotly/plotly.py.git
octolytics-dimension-user_id5997976
octolytics-dimension-user_loginplotly
octolytics-dimension-repository_id14579099
octolytics-dimension-repository_nwoplotly/plotly.py
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14579099
octolytics-dimension-repository_network_root_nwoplotly/plotly.py
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release602250ea3b6dd8302a7220ef98adb828dbc807e4
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/plotly/plotly.py/issues/1098#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fplotly%2Fplotly.py%2Fissues%2F1098
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fplotly%2Fplotly.py%2Fissues%2F1098
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=plotly%2Fplotly.py
Reloadhttps://github.com/plotly/plotly.py/issues/1098
Reloadhttps://github.com/plotly/plotly.py/issues/1098
Reloadhttps://github.com/plotly/plotly.py/issues/1098
Please reload this pagehttps://github.com/plotly/plotly.py/issues/1098
plotly https://github.com/plotly
plotly.pyhttps://github.com/plotly/plotly.py
Please reload this pagehttps://github.com/plotly/plotly.py/issues/1098
Notifications https://github.com/login?return_to=%2Fplotly%2Fplotly.py
Fork 2.8k https://github.com/login?return_to=%2Fplotly%2Fplotly.py
Star 18.7k https://github.com/login?return_to=%2Fplotly%2Fplotly.py
Code https://github.com/plotly/plotly.py
Issues 721 https://github.com/plotly/plotly.py/issues
Pull requests 54 https://github.com/plotly/plotly.py/pulls
Actions https://github.com/plotly/plotly.py/actions
Security and quality 0 https://github.com/plotly/plotly.py/security
Insights https://github.com/plotly/plotly.py/pulse
Code https://github.com/plotly/plotly.py
Issues https://github.com/plotly/plotly.py/issues
Pull requests https://github.com/plotly/plotly.py/pulls
Actions https://github.com/plotly/plotly.py/actions
Security and quality https://github.com/plotly/plotly.py/security
Insights https://github.com/plotly/plotly.py/pulse
New module proposal: plotly.iohttps://github.com/plotly/plotly.py/issues/1098#top
https://github.com/jonmmease
jonmmeasehttps://github.com/jonmmease
on Aug 7, 2018https://github.com/plotly/plotly.py/issues/1098#issue-348393685
orcahttps://github.com/plotly/orca
plotly-rendererhttps://github.com/jupyterlab/jupyter-renderers/tree/master/packages/plotly-extension
chart editorhttps://github.com/plotly/jupyterlab-chart-editor
HDFS filesystem using PyArrowhttps://arrow.apache.org/docs/python/filesystems.html
@chriddyphttps://github.com/chriddyp
@cldouglhttps://github.com/cldougl
@Kullyhttps://github.com/Kully
@nicolaskruchtenhttps://github.com/nicolaskruchten
@jackparmerhttps://github.com/jackparmer
@bcdunbarhttps://github.com/bcdunbar
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.