Repository: biolab/orange3

Issue:
PCA: scree plot formatted strangely when resetting zoom
<!-- 
Thanks for taking the time to report a bug!
If you're raising an issue about an add-on (i.e., installed via Options > Add-ons), raise an issue in the relevant add-on's issue tracker instead. See: https://github.com/biolab?q=orange3
To fix the bug, we need to be able to reproduce it. Please answer the following questions to the best of your ability.
-->


- [ ] **What's wrong?**
<!-- Be specific, clear, and concise. Include screenshots if relevant. -->
<!-- If you're getting an error message, copy it, and enclose it with three backticks (```). -->
Scree plot in PCA is not nicely formatted upon resetting the zoom. Also the new curve labels fall out of view when resizing the widget.




- [ ] **How can we reproduce the problem?** 
<!-- Upload a zip with the .ows file and data. -->
<!-- Describe the steps (open this widget, click there, then add this...) -->
File (brown-selected).
PCA. Press the reset zoom option in the bottom left corner of the plot. This happens:
<img width="695" alt="Screen Shot 2021-02-17 at 10 48 08" src="https://user-images.githubusercontent.com/12524972/108192774-f7772f80-7114-11eb-86f0-7da69aecbc46.png">
Also, component variance and cumulative variance fall out of view when the widget size is small. Perhaps set them within the two curves, not on the outside.




- [ ] **What's your environment?**
<!-- To find your Orange version, see "Help → About → Version" or `Orange.version.full_version` in code -->
- Operating system: OSX
- Orange version: 3.28.dev
- How you installed Orange: conda



Discussion:

Resolving patch:
diff --git a/Orange/widgets/utils/slidergraph.py b/Orange/widgets/utils/slidergraph.py
--- a/Orange/widgets/utils/slidergraph.py
+++ b/Orange/widgets/utils/slidergraph.py
@@ -36,6 +36,7 @@ def __init__(self, x_axis_label, y_axis_label, callback):
         self.getViewBox().setMouseEnabled(False, False)
         self.showGrid(True, True, alpha=0.5)
         self.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0))
+        self.hideButtons()
 
         # tuples to store horisontal lines and labels
         self.plot_horlabel = []
@@ -96,8 +97,7 @@ def update(self, x, y, colors, cutpoint_x=None, selection_limit=None,
                 self.addItem(label)
 
         self._plot_cutpoint(cutpoint_x)
-        self.setRange(xRange=(x.min(), x.max()),
-                      yRange=(0, max(yi.max() for yi in y)))
+        self.autoRange()
 
     def clear_plot(self):
         """
@@ -198,11 +198,12 @@ def _update_horizontal_lines(self):
         # in every case set their position
         location = int(round(self._line.value()))
         cutidx = np.searchsorted(self.x, location)
+        minx = np.min(self.x)
         for s, curve, label, inc in zip(
                 self.sequences, self.plot_horline, self.plot_horlabel,
                 self.data_increasing):
             y = s[cutidx]
-            curve.setData([-100, location], 2 * [y])
+            curve.setData([minx, location], [y, y])
             self._set_anchor(label, cutidx, inc)
             label.setPos(location, y)
             label.setPlainText("{:.3f}".format(y))


Test patch: