Repository: deepchecks/deepchecks

Issue:
[BUG] Drift score bars are zoomable
When clicking on the zoom in/out buttons, it affects the distribution plot and also the score bar.\
The score bar should be static.

before zoom:
![image](https://user-images.githubusercontent.com/9868530/149982236-8db8aedf-e990-4f94-b1b9-4091c094933a.png)
after zoom:
![image](https://user-images.githubusercontent.com/9868530/149982312-c3c4d606-f545-4165-aca4-8ef298406044.png)



Discussion:

Resolving patch:
diff --git a/deepchecks/checks/distribution/whole_dataset_drift.py b/deepchecks/checks/distribution/whole_dataset_drift.py
--- a/deepchecks/checks/distribution/whole_dataset_drift.py
+++ b/deepchecks/checks/distribution/whole_dataset_drift.py
@@ -188,34 +188,18 @@ def auc_to_drift_score(auc: float) -> float:
 
     def _build_drift_plot(self, score):
         """Build traffic light drift plot."""
-        stop = max(0.4, score + 0.1)
-
-        drift = drift_score_bar_traces(score)
-
+        bar_traces, x_axis, y_axis = drift_score_bar_traces(score)
+        x_axis['title'] = 'Drift score'
         drift_plot = go.Figure(layout=dict(
             title='Drift Score - Whole Dataset Total',
-            xaxis=dict(
-                showgrid=False,
-                gridcolor='black',
-                linecolor='black',
-                range=[0, stop],
-                dtick=0.05,
-                title='drift score'
-            ),
-            yaxis=dict(
-                showgrid=False,
-                showline=False,
-                showticklabels=False,
-                zeroline=False,
-                color='black'
-            ),
+            xaxis=x_axis,
+            yaxis=y_axis,
             width=700,
             height=200
 
         ))
 
-        drift_plot.add_traces(drift)
-
+        drift_plot.add_traces(bar_traces)
         return drift_plot
 
     def _display_dist(self, train_column: pd.Series, test_column: pd.Series, fi_ser: pd.Series):
diff --git a/deepchecks/utils/distribution/drift.py b/deepchecks/utils/distribution/drift.py
--- a/deepchecks/utils/distribution/drift.py
+++ b/deepchecks/utils/distribution/drift.py
@@ -21,6 +21,7 @@
 
 from deepchecks.utils.distribution.plot import drift_score_bar_traces, feature_distribution_traces
 from deepchecks.utils.distribution.preprocessing import preprocess_2_cat_cols_to_same_bins
+from deepchecks.errors import DeepchecksValueError
 
 PSI_MIN_PERCENTAGE = 0.01
 
@@ -114,47 +115,35 @@ def calc_drift_and_plot(train_column: pd.Series, test_column: pd.Series, plot_ti
         test_dist = test_dist.astype('float')
 
         score = earth_movers_distance(dist1=train_dist, dist2=test_dist)
-        bar_stop = max(0.4, score + 0.1)
 
-        score_bar = drift_score_bar_traces(score)
-
-        traces, xaxis_layout, yaxis_layout = feature_distribution_traces(train_dist, test_dist)
+        bar_traces, bar_x_axis, bar_y_axis = drift_score_bar_traces(score)
+        dist_traces, dist_x_axis, dist_y_axis = feature_distribution_traces(train_dist, test_dist)
 
     elif column_type == 'categorical':
         scorer_name = 'PSI'
         expected_percents, actual_percents, _ = \
             preprocess_2_cat_cols_to_same_bins(dist1=train_dist, dist2=test_dist, max_num_categories=max_num_categories)
         score = psi(expected_percents=expected_percents, actual_percents=actual_percents)
-        bar_stop = min(max(0.4, score + 0.1), 1)
-
-        score_bar = drift_score_bar_traces(score)
 
-        traces, xaxis_layout, yaxis_layout = feature_distribution_traces(train_dist, test_dist, is_categorical=True,
-                                                                         max_num_categories=max_num_categories)
+        bar_traces, bar_x_axis, bar_y_axis = drift_score_bar_traces(score, bar_max=1)
+        dist_traces, dist_x_axis, dist_y_axis = feature_distribution_traces(train_dist, test_dist, is_categorical=True,
+                                                                            max_num_categories=max_num_categories)
+    else:
+        # Should never reach here
+        raise DeepchecksValueError(f'Unsupported column type for drift: {column_type}')
 
     fig = make_subplots(rows=2, cols=1, vertical_spacing=0.4, shared_yaxes=False, shared_xaxes=False,
                         row_heights=[0.1, 0.9],
                         subplot_titles=['Drift Score - ' + scorer_name, plot_title])
 
-    fig.add_traces(score_bar, rows=[1] * len(score_bar), cols=[1] * len(score_bar))
-    fig.add_traces(traces, rows=[2] * len(traces), cols=[1] * len(traces))
+    fig.add_traces(bar_traces, rows=[1] * len(bar_traces), cols=[1] * len(bar_traces))
+    fig.add_traces(dist_traces, rows=[2] * len(dist_traces), cols=[1] * len(dist_traces))
 
     shared_layout = go.Layout(
-        xaxis=dict(
-            showgrid=False,
-            gridcolor='black',
-            linecolor='black',
-            range=[0, bar_stop],
-            dtick=0.05
-        ),
-        yaxis=dict(
-            showgrid=False,
-            showline=False,
-            showticklabels=False,
-            zeroline=False,
-        ),
-        xaxis2=xaxis_layout,
-        yaxis2=yaxis_layout,
+        xaxis=bar_x_axis,
+        yaxis=bar_y_axis,
+        xaxis2=dist_x_axis,
+        yaxis2=dist_y_axis,
         legend=dict(
             title='Dataset',
             yanchor='top',
diff --git a/deepchecks/utils/distribution/plot.py b/deepchecks/utils/distribution/plot.py
--- a/deepchecks/utils/distribution/plot.py
+++ b/deepchecks/utils/distribution/plot.py
@@ -16,7 +16,7 @@
 
 __all__ = ['feature_distribution_traces', 'drift_score_bar_traces', 'get_density']
 
-from typing import List, Union, Dict
+from typing import List, Union, Dict, Tuple
 
 from deepchecks.utils.distribution.preprocessing import preprocess_2_cat_cols_to_same_bins
 from deepchecks.utils.plot import colors
@@ -42,12 +42,12 @@ def get_density(data, xs) -> np.ndarray:
     return density(xs)
 
 
-def drift_score_bar_traces(drift_score: float) -> List[go.Bar]:
+def drift_score_bar_traces(drift_score: float, bar_max: float = None) -> Tuple[List[go.Bar], Dict, Dict]:
     """Create a traffic light bar traces for drift score.
 
     Args:
         drift_score (float): Drift score
-
+        bar_max (float): Maximum value for the bar
     Returns:
         List[go.Bar]: list of plotly bar traces.
     """
@@ -64,7 +64,8 @@ def drift_score_bar_traces(drift_score: float) -> List[go.Bar]:
             break
 
         bars.append(go.Bar(
-            x=[min(drift_score, range_tuple[1]) - range_tuple[0]], y=['Drift Score'],
+            x=[min(drift_score, range_tuple[1]) - range_tuple[0]],
+            y=['Drift Score'],
             orientation='h',
             marker=dict(
                 color=color,
@@ -75,14 +76,34 @@ def drift_score_bar_traces(drift_score: float) -> List[go.Bar]:
 
         ))
 
-    return bars
+    bar_stop = max(0.4, drift_score + 0.1)
+    if bar_max:
+        bar_stop = min(bar_stop, bar_max)
+    xaxis = dict(
+        showgrid=False,
+        gridcolor='black',
+        linecolor='black',
+        range=[0, bar_stop],
+        dtick=0.05,
+        fixedrange=True
+    )
+    yaxis = dict(
+        showgrid=False,
+        showline=False,
+        showticklabels=False,
+        zeroline=False,
+        color='black',
+        fixedrange=True
+    )
+
+    return bars, xaxis, yaxis
 
 
 def feature_distribution_traces(train_column,
                                 test_column,
                                 is_categorical: bool = False,
                                 max_num_categories: int = 10,
-                                quantile_cut: float = 0.02) -> [List[Union[go.Bar, go.Scatter]], Dict, Dict]:
+                                quantile_cut: float = 0.02) -> Tuple[List[Union[go.Bar, go.Scatter]], Dict, Dict]:
     """Create traces for comparison between train and test column.
 
     Args:


Test patch: