Rectangle zoom¶
Rectangle zoom is disabled by default. Enable it on Plot or PlotView:
- 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.minimumSizelogical pixels wide and high, 6 by default. rectangleZoom.modifiersmust match exactly at press time; useQt.NoModifierfor unmodified dragging. ASelectionTooluses Shift + left drag by default; if both are set to the same gesture, theSelectionTooltakes it.rectangleZoom.fillColorandborder.colordefault to the dark palette'srectangleZoomFillandrectangleZoomBorder. Bind them toColors.lightfor a light theme.border.widthis 1 by default.- To draw the selection yourself, set
rectangleZoom.visible: falseand bind an item inplot.overlaytorectangleZoom.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:
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