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 new residuals_plot? #201

Open
nvaytet opened this issue Apr 13, 2023 · 14 comments
Open

Add a new residuals_plot? #201

nvaytet opened this issue Apr 13, 2023 · 14 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@nvaytet
Copy link
Member

nvaytet commented Apr 13, 2023

This example shows how to make a plot of multiple lines with a residual difference panel below the main plot.

Is this something that is common enough that we could have a dedicated function for creating it?
For example, plopp.residual_plot(b, c, reference=a) would show 3 lines in the main panel and b-a and c-a in the residuals panel.

I guess it would be most useful if it could be used as a view in a graph of nodes, and not just a single purpose function.
This would mean that it could be used in combination with a slider, where both the main panel and the residuals would update when moving the slider.

@nvaytet nvaytet added the help wanted Extra attention is needed label Apr 13, 2023
@jl-wynen
Copy link
Member

Kind of along the lines of your graph comment: Did you consider making these functions composable, e.g. using pp.plot(b, c).plot_residuals(reference=a, location=bottom). This could also be used to add slicers, etc.
Or would you rather people go through the graph directly?

@nvaytet
Copy link
Member Author

nvaytet commented Apr 17, 2023

Interesting, but I am now sure I get what would pp.plot(b, c).plot_residuals(reference=a, location=bottom) show?
And how would you add sliders with that syntax?

@jl-wynen
Copy link
Member

It would create the base plot, then create the residuals plot from the data in the base plot and arrange everything into a single figure. Basically the same that your residual_plot would do except it goes through an intermediate plot (graph).

@nvaytet
Copy link
Member Author

nvaytet commented Apr 17, 2023

So in your example a would not show up on the main plot. Is that ok?

@jl-wynen
Copy link
Member

What does plopp.residual_plot(b, c, reference=a) actually do? Does it plot 3 lines?

@nvaytet
Copy link
Member Author

nvaytet commented Apr 17, 2023

I thought you would have 3 lines in the main plot and 2 lines in the small panel below.

@nvaytet
Copy link
Member Author

nvaytet commented Apr 17, 2023

Actually, scratch that, I thought I had written plopp.residual_plot(a, b, c, reference=a) above...

@nvaytet
Copy link
Member Author

nvaytet commented Apr 17, 2023

So pp.plot(a, b, c).residuals(reference=a) ?

@jl-wynen
Copy link
Member

Yes

@nvaytet
Copy link
Member Author

nvaytet commented Apr 17, 2023

I'm starting to think that to make this work in a generic way, we would need to be able to stitch two graphs together.

For example, the way I was first imagining I would implement this residuals_plot would be with 3 input nodes (for a, b, and c), one figure that takes all 3 as input. Then add 2 more nodes which do b-a and c-a, and then another figure that takes those two nodes as input.

But if you would like to use this as a final extra viz after you've performed other operations such as changing a fitting parameter with a slider, then you would want to add this 'sub-graph' to the other graph which has the slider, to make a large graph.

So maybe we do need a Graph object that would handle composing large graphs from smaller components, like the transform_coords? This would maybe make things like the slicing with a slider more re-usable?

@nvaytet
Copy link
Member Author

nvaytet commented Aug 2, 2023

Or maybe it's just that all the functions like plot or slicer should accept both Node and raw data as input.
They would then be very re-useable?

@nvaytet
Copy link
Member Author

nvaytet commented Aug 4, 2023

Or maybe it's just that all the functions like plot or slicer should accept both Node and raw data as input. They would then be very re-useable?

Continuing on this idea, I think we should use nodes a lot more in the high level plotting functions.
For example, all the data pre-processing we do at the start of the plot function is just operating on the raw input. Instead, the preprocessing step should just be another node in the graph.

@nvaytet
Copy link
Member Author

nvaytet commented Sep 22, 2023

See #254

@nvaytet nvaytet added the enhancement New feature or request label Sep 26, 2023
@nvaytet
Copy link
Member Author

nvaytet commented Oct 26, 2023

@jl-wynen
Looking at https://scipp.github.io/plopp/customization/subplots.html#Using-tiled:, could we use the - operator to make residual plots?
E.g. a.plot() - b.plot() would make a plot with both a and b on the top panel, and then a - b on the lower panel.
This would be slower than a dedicated function, because you first have to create both plots, only to destroy them and start again, but the syntax is nice and quite clear?

If you wanted more than one line you could do pp.plot({'a': a, 'b': b, 'c': c}) - d.plot() ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants