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

Fix y-axis range of main plot in dataviewer from 0 to 1 when P1 data type #226

Merged
merged 5 commits into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion iquip/apps/dataviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,11 @@ def setData(self, data: np.ndarray, axes: Sequence[AxisInfo]):
logger.error("MainPlotWidget does not support %d-dim data", data.ndim)
return
self.viewers[plotType].setData(data, axes)
self.stack.setCurrentIndex(plotType)
if self.autoRangeBox.isChecked():
plotItem = self.viewers[plotType].plotItem
bounds = plotItem.getViewBox().childrenBoundingRect(items=None)
plotItem.setXRange(bounds.left(), bounds.right())
self.stack.setCurrentIndex(plotType)
BECATRUE marked this conversation as resolved.
Show resolved Hide resolved

def _mouseClicked(self, viewer: NDArrayViewer, event: mouseEvents.MouseClickEvent):
"""Mouse is clicked on the plot.
Expand Down Expand Up @@ -1158,6 +1158,8 @@ def updateMainPlot(self, axis: Sequence[int], dataType: DataPointWidget.DataType
reduce = self._reduceFunction(dataType)
data, axes = self.policy.extract(axis, reduce)
self.frame.mainPlotWidget.setData(data, axes)
if data.ndim == 1 and dataType == DataPointWidget.DataType.P1:
self.frame.mainPlotWidget.viewer().plotItem.setYRange(0, 1)
index = self.dataPointIndex
if data.ndim == len(index) and np.all(np.less(index, data.shape)):
self.selectDataPoint(index)
Expand Down