@@ -38,9 +38,10 @@ def __init__(self, *, ax: MplAxes, figure=None) -> None:
3838 self .collections = []
3939 self .images = []
4040
41- # Make background to enable box zoom
41+ # Make background to enable box zoom.
42+ # Use a size based on limits of the float32 range.
4243 self ._background_geometry = p3 .PlaneGeometry (
43- width = 2 , height = 2 , widthSegments = 1 , heightSegments = 1
44+ width = 6e38 , height = 6e38 , widthSegments = 1 , heightSegments = 1
4445 )
4546 self ._background_material = p3 .MeshBasicMaterial (color = self .background_color )
4647 self ._background_mesh = p3 .Mesh (
@@ -329,18 +330,6 @@ def autoscale(self):
329330 else (1.0 if self .get_yscale () == "linear" else 10.0 )
330331 )
331332
332- self ._background_mesh .geometry = p3 .PlaneGeometry (
333- width = 2 * (self ._xmax - self ._xmin ),
334- height = 2 * (self ._ymax - self ._ymin ),
335- widthSegments = 1 ,
336- heightSegments = 1 ,
337- )
338-
339- self ._background_mesh .position = [
340- 0.5 * (self ._xmin + self ._xmax ),
341- 0.5 * (self ._ymin + self ._ymax ),
342- self ._background_mesh .position [- 1 ],
343- ]
344333 self .reset ()
345334
346335 def add_artist (self , artist ):
@@ -577,10 +566,10 @@ def zoom(self, box):
577566 "ymax" : box [3 ],
578567 }
579568 with self .camera .hold_trait_notifications ():
580- self .camera .left = self ._zoom_limits ["xmin" ]
581- self .camera .right = self ._zoom_limits ["xmax" ]
582- self .camera .bottom = self ._zoom_limits ["ymin" ]
583- self .camera .top = self ._zoom_limits ["ymax" ]
569+ self .camera .left = self ._zoom_limits ["xmin" ] - self . camera . position [ 0 ]
570+ self .camera .right = self ._zoom_limits ["xmax" ] - self . camera . position [ 0 ]
571+ self .camera .bottom = self ._zoom_limits ["ymin" ] - self . camera . position [ 1 ]
572+ self .camera .top = self ._zoom_limits ["ymax" ] - self . camera . position [ 1 ]
584573 if self .get_xscale () == "log" :
585574 xlim = (
586575 10.0 ** self ._zoom_limits ["xmin" ],
0 commit comments