From 37f62823afbb83047ba8e8c3938ca62f0aa20f65 Mon Sep 17 00:00:00 2001 From: Midhun PM Date: Thu, 2 Jan 2020 11:45:47 -0600 Subject: [PATCH] Fix zoomout issues in examples financial/correlations.py, financial/stock_prices.py, shell/dates.py --- examples/demo/financial/correlations.py | 4 ++-- examples/demo/financial/stock_prices.py | 4 +++- examples/demo/shell/dates.py | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/demo/financial/correlations.py b/examples/demo/financial/correlations.py index af3fd6ebf..a740da19c 100644 --- a/examples/demo/financial/correlations.py +++ b/examples/demo/financial/correlations.py @@ -96,8 +96,8 @@ def _create_returns_plot(self): renderer.tools.append(RangeSelection(renderer, left_button_selects = False, auto_handle_event = False)) plot.tools.append(PanTool(plot, drag_button="left", constrain=True, - constrain_direction="x")) - plot.overlays.append(ZoomTool(plot, tool_mode="range", max_zoom_out=1.0)) + constrain_direction="x", restrict_to_data=True)) + plot.overlays.append(ZoomTool(plot, tool_mode="range", max_zoom_out=1.0, x_min_zoom_factor=float(1e-3))) # Attach the range selection to the last renderer; any one will do self._range_selection_overlay = RangeSelectionOverlay(renderer, metadata_name="selections") diff --git a/examples/demo/financial/stock_prices.py b/examples/demo/financial/stock_prices.py index 544c294f8..f7e0d7655 100644 --- a/examples/demo/financial/stock_prices.py +++ b/examples/demo/financial/stock_prices.py @@ -67,12 +67,14 @@ def _create_price_plots(self, times, prices, mini_height=75): # Add pan and zoom price_plot.tools.append(PanTool(price_plot, constrain=True, - constrain_direction="x")) + constrain_direction="x", + restrict_to_data=True)) price_plot.overlays.append(ZoomTool(price_plot, drag_button="right", always_on=True, tool_mode="range", axis="index", max_zoom_out_factor=1.0, + x_min_zoom_factor=float(1e-3) )) # Create the miniplot diff --git a/examples/demo/shell/dates.py b/examples/demo/shell/dates.py index 84081f3d9..fb21a943a 100644 --- a/examples/demo/shell/dates.py +++ b/examples/demo/shell/dates.py @@ -30,8 +30,14 @@ # Add some titles title("Plotting Dates") +current_plot = curplot() # Set the plot's horizontal axis to be a time scale -curplot().x_axis.tick_generator.scale = CalendarScaleSystem() +current_plot.x_axis.tick_generator.scale = CalendarScaleSystem() +zoom_tool = current_plot.overlays[2] +pan_tool = current_plot.tools[0] +zoom_tool.x_min_zoom_factor = float(1e-3) +pan_tool.restrict_to_data = True + # This command is only necessary if running from command line show()