-
Notifications
You must be signed in to change notification settings - Fork 5
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 inspector tool #29
Conversation
docs/inspector-plot.ipynb
Outdated
"source": [ | ||
"# Inspector plot\n", | ||
"\n", | ||
"The `inspector` plot is for three-dimensional data.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good name, I think.
For the future: I could imagine using this for 2-D data, in two ways:
- 1-D plot with 1-D profile.
- 2-D plot with inspected values displayed in a table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "1-D plot with 1-D profile." as we had it in the old plotting, with adding vertical line markers was pretty useless.
For that, I am thinking more of having a superplot
(like Lamp's superplot), which is like the slicer
plot: you slice 2d data to get a 1d plot with a slider. In addition, you have buttons to save the current line. I think it's better than clicking on the figure to see a cut in the other dimension.
"2-D plot with inspected values displayed in a table.": good idea 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "1-D plot with 1-D profile." as we had it in the old plotting, with adding vertical line markers was pretty useless.
Not necessarily: Consider {'spectrum':1_000_000, 'tof':1000}
. We cannot make a 2-D plot anymore, but someone might want to make a 1-D plot of the counts per spectrum and then inspect and compare TOF-spectra from different pixels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you suggest is a little different, because the inspector
plot does no summing along the third dimension.
So in your example, the first plot wouldn't be the counts per spectrum, it would be the counts per spectrum in the first tof bin.
I guess you could easily make this by adding a summing node in the graph.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you suggest is a little different, because the inspector plot does no summing along the third dimension.
Without sum this does not seem very useful? In many cases a single slice does not contain useful values to display?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So are you saying that inspector
should also sum along the third dimension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we allow different operations, such as sum, mean, min, max
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So are you saying that
inspector
should also sum along the third dimension?
Yes.
docs/inspector-plot.ipynb
Outdated
"- Left-click to make new point\n", | ||
"- Left-click and hold on point to move point\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"- Left-click to make new point\n", | |
"- Left-click and hold on point to move point\n", | |
"- Click to make new point\n", | |
"- Drag existing point to move it\n", |
or something like that?
@@ -14,7 +14,7 @@ | |||
plt.ioff() | |||
|
|||
from .core import Node, node, input_node, widget_node, show_graph, View | |||
from .functions import figure, plot, slicer | |||
from .functions import figure, plot, slicer, inspector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider our import strategy: I feel some things should stay optional dependencies. I do not know if mpltoolbox
is one of them, but pythreejs
(for 3D scatter plots) should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently mpltoolbox
is optional. It only gets imported when inspector
is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we should probably think about reviewing the code in mpltoolbox
, and also making it available on conda
.
src/plopp/functions/inspector.py
Outdated
from scipp import Variable, scalar | ||
from scipp.typing import VariableLike |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I importing without namespace good style? As this is not part of scipp anymore we should maybe just import scipp as sc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, i'm also importing things from ipywidgets
like that. e.g. from ipywidgets import VBox
.
I thought it is cheaper than importing the whole of ipywidgets
, but maybe it makes no difference in practise because it still has to run through the whole __init__.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is a question of style, and we have never made a clear decision on that.
src/plopp/functions/inspector.py
Outdated
|
||
event_nodes = {} | ||
|
||
def make_node(change): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for the design choice of nested functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason. It was the easiest. I can refactor.
src/plopp/graphics/interactive.py
Outdated
@@ -81,23 +81,23 @@ def home(self): | |||
self.crop(**self._crop) | |||
self.draw() | |||
|
|||
def pan(self): | |||
def pan(self, *_): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silently ignoring other args? Why and where is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the ToggleButton
tool to send its current value when it is pressed, so that the PointsTool
can decide whether to start or stop.
In this particular case, we use the tool state from the matplotlib figure to determine which zoom or pan tool should be active. So we don't actually care about the value
of the tool for pan
and zoom
(we could care for logx
, logy
but not necessarily, cf the current implementation).
That said, in the current implementation the PointsTool
is actually a ToggleTool
and it knows its current value, so I could just do
def start_stop(self):
if self.value:
self.points.start()
else:
self.points.stop()
and no need to send the value when the button is toggled.
I guess I was thinking of future toggle tools, that might call a method that is not part of the class, and that might need the value in the callback message.
But that could be in the future. I am happy to just remove the value from the call, and remove the *_
from the fig.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That, or at least add some documentation about what is going on.
…tion operation along the third dimension
This is a tool for inspecting the 3rd dimension of 3d data by placing dots on a 2d image.
The dots indicate where to slice out the displayed dimensions, only to leave the 3rd dim.
The resulting 1d plot is shown on a new figure.
Points can be moved around, and removed.
Example:
Fixes #28