Skip to content

Rectangle zoom

Rectangle zoom is disabled by default. Enable it on Plot or PlotView:

import QAccelPlot as QAccelPlot

QAccelPlot.Plot {
    rectangleZoom.enabled: true
}
  • Ctrl + left drag (Command on macOS) selects a region; release to zoom all attached axes.
  • Escape cancels. Double-click rescales to the data. Ordinary left dragging pans.
  • The selection is clipped to the plot area and must be at least rectangleZoom.minimumSize logical pixels wide and high, 6 by default.
  • rectangleZoom.modifiers must match exactly at press time; use Qt.NoModifier for unmodified dragging. A SelectionTool uses Shift + left drag by default; if both are set to the same gesture, the SelectionTool takes it.
  • rectangleZoom.fillColor and border.color default to the dark palette's rectangleZoomFill and rectangleZoomBorder. Bind them to Colors.light for a light theme. border.width is 1 by default.
  • To draw the selection yourself, set rectangleZoom.visible: false and bind an item in plot.overlay to rectangleZoom.selectionRect, which is empty while no selection is in progress. See Selection for an example.

For a custom tool, call zoomToRect() with item-local pixels:

const applied = plot.zoomToRect(Qt.rect(left, top, width, height))

It works with gestures disabled and supports logarithmic and reversed axes. It returns false without changing ranges if the selection or target axes are invalid.

Complete source: examples/plot_types/point_cloud