scipp / plopp

Visualization library for scipp
https://scipp.github.io/plopp/
BSD 3-Clause "New" or "Revised" License
7 stars 5 forks source link

Add a method to convert plots to dict? #203

Open nvaytet opened 1 year ago

nvaytet commented 1 year ago

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):

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

nvaytet commented 1 year ago

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 commented 1 year ago

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