Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store PlotlyJSON directly in the project model? #1745

Closed
brollb opened this issue Jul 6, 2020 · 5 comments
Closed

Store PlotlyJSON directly in the project model? #1745

brollb opened this issue Jul 6, 2020 · 5 comments
Assignees
Milestone

Comments

@brollb
Copy link
Contributor

brollb commented Jul 6, 2020

Working on the interactive tensor plotting capabilities has brought some issues to light with the current approach taken with plots. The tensor plotting capabilities include plotting one-dimensional tensors as shown below.

DeepinScreenshot_20200703093236

However, this can not be represented in the current metamodel nor the matplotlib backend (required for reproducing the plot). The main issue here is not just that it isn't supported but that adding support requires changes to the metamodel and the matplotlib backend (which is already somewhat large).

Alternatively, we could simply store the plotly JSON directly in our metamodel. This should greatly simplify the matplotlib backend code as it can just use plotly.tool.mpl_to_plotly and would provide support for almost all plots immediately - rather than adding custom code for each one (where it feels like we have begun to reinvent the wheel).

@brollb
Copy link
Contributor Author

brollb commented Jul 6, 2020

One remaining challenge would be to add support for click/selection events: https://plotly.com/javascript/plotlyjs-events/

This isn't any harder using this approach but it is something that has not been covered here.

@umesh-timalsina
Copy link
Contributor

There will be following questions:

  1. The current metamodel for storing figure info is as shown below:
    image
    What will be the approach to store a PlotlyJSON into a metamodel?

  2. Should we distinguish subplots and plots metanodes?

@brollb
Copy link
Contributor Author

brollb commented Jul 6, 2020

Since the plotly JSON, has all this info, we might be able to just update the Graph node to have a data field with the plotly JSON.

@brollb
Copy link
Contributor Author

brollb commented Jul 6, 2020

As far as the second question, ideally we would be able to contain all the info in the single node and allow plotly JSON to contain the subfigure info.

@umesh-timalsina
Copy link
Contributor

umesh-timalsina commented Jul 6, 2020

There are couple of challenges with the current approach:

See plotly/plotly.py#2621

  1. Exporting Images with mpl_to_plotly is not yet supported.
Aw. Snap! You're gonna have to hold off on the selfies for now. Plotly can't import images from matplotlib yet!
  1. Exporting 3D plots with mpl_to_plotly is not yet supported.

The solution proposed here would be largely delegating creating of plotly JSON from JavaScript to Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants