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

Add a method to convert plots to dict? #203

Open
nvaytet opened this issue Apr 24, 2023 · 2 comments
Open

Add a method to convert plots to dict? #203

nvaytet opened this issue Apr 24, 2023 · 2 comments

Comments

@nvaytet
Copy link
Member

nvaytet commented Apr 24, 2023

It may be useful to have the ability to convert plots to a dict that would fully specify the figure.
Just like Scipp has .to_dict(), we could have something that would convert the plot to a dict which would be interpretable and plotted using any plotting library, not just Matplotlib.

The dict would contain all the info needed to build the figure (non-exhaustive list):

  • the number of axes
  • the limits of the axes
  • the axes labels
  • the type of plot (lines or image or contours...)
  • the data to plot
  • the font sizes
  • the figure title

A python dict is easily convertible to JSON, making sending the data somewhere else more easy.

@nvaytet
Copy link
Member Author

nvaytet commented Apr 24, 2023

Sunyoung and I discussed the possibility of using something like this to send the data to the dashboard for the live view. Let plopp interpet the data array and make a figure, and then send it as a dict or json to the dashboard, which can then use matplotlib or plotly or something else to re-create the figure.

The idea was to not have to re-create the logic we already have in plopp (what to do if data you receive is 1d or 2d etc..) in the dashboard if we use a library that is not Matplotlib (e.g. plotly).

@nvaytet
Copy link
Member Author

nvaytet commented Apr 25, 2023

See https://discuss.scientific-python.org/t/is-there-a-plotting-standard-api-in-python-like-the-array-and-dataframe-standard-apis/715

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

No branches or pull requests

1 participant