EMAworkbench icon indicating copy to clipboard operation
EMAworkbench copied to clipboard

[Feature] Support inputting multiple points (in a list) with PrimBox.inspect()

Open EwoutH opened this issue 2 years ago • 4 comments

Instead of only inspecting one point, it would be neat if you can pass multiple points into the inspect() function of an analysis.prim.PrimBox. The expected behavior could be:

  • [x] For PrimBox.inspect(i=list, style="table"), a dataframe with a row for each point will be provided.
  • [ ] For PrimBox.inspect(i=list, style="graph"), either Figure with a subplot for each point could be provided, or a single graph with the multiple points compared to each other (each point with a different color bars).

This will allow to more quickly inspect and compare multiple points on the peeling trajectory.

Also I noted that the inspect function prints a lot of data without returning it. I think it's nicer and more expected to return the values/tables/graphs, and let the user print them. That way you can use them in further analysis if you want.

EwoutH avatar May 13 '22 15:05 EwoutH

Implementing this is largely straightforward. Basically move most of the current code in inspect into some protected function _inspect, and then possibly loop over this depending on whether i is an integer or a list.

If we want to also control for style='graph' whether to show each box as a separate figure or have them in a single figure, then things become messier. My hunch is that it would actually break the current visualization, because of overplotting the values of the box limits as well as having to handle multiple quasi-p values (one for each box lim).

Not sure what you mean exactly by your last remark. Given that the printing to screen is a bit more involved than simply creating the DataFrame (see line 455 in prim.py ). There is a usecase for returning a DataFrame-like representation of the box lims which you can then send this to the clipboard for use in a report or something. I would, however, be inclined to treat that as a third option for the style kwarg.

quaquel avatar Jun 01 '22 06:06 quaquel

If we want to also control for style='graph' whether to show each box as a separate figure or have them in a single figure, then things become messier.

I think it would be nice to create subplot for each point and their box, and then return a single figure. We could set a default number of subplots that fit next to each other horizontally, 3 for example, and extend vertically as more points get plotted. I can work on this piece a bit.

Not sure what you mean exactly by your last remark.

You got it almost exactly right :). I like the idea of having separate style kwargs for printing and returning data. I think a set/tuple/dictionary of DataFrames might be the way to go.

EwoutH avatar Jun 01 '22 07:06 EwoutH

The easiest next step for the visualization would be to modify scenario_discovery_util.plot_box to take an optional axes instance as a kwarg (similar to how you can do this in seaborn). scenario_discovery_util._setup_figure then needs to be modified (and renamed) to operate on a provided. A quick check of the code suggests that with those changes, all you need to do is set up a figure with arbitrary rows and cols and simply iterate over the resulting axes and plot a single box in each axes.

quaquel avatar Jun 01 '22 17:06 quaquel

Let's move the "graph" part to 2.4.0, as part of a larger plotting overhaul.

EwoutH avatar Oct 28 '22 10:10 EwoutH