Repository: biolab/orange3

Issue:
Negative regressions are printed upside-down
<!-- 
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 (```). -->

As shown in the attached screenshot, if a regression line has a negative slope, the _r_ value is printed upside-down.  I really can’t imagine that it would be common for viewers to prefer that.  The second screenshot also demonstrates that the positioning of the label does not take the markers in the view into account, so the text can be completely lost.

**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...) -->

The attached worksheet demonstrates the issue.  Just open the Scatterplot widget.



**What's your environment?**
<!-- To find your Orange version, see "Help → About → Version" or `Orange.version.full_version` in code -->
- Operating system: macOS 12.0.1
- Orange version: 3.30.2
- How you installed Orange: From the disk image at https://download.biolab.si/download/files/Orange3-3.30.2-Python3.8.8.dmg

<img width="777" alt="Screenshot 2021-12-06 at 01 21 32" src="https://user-images.githubusercontent.com/10616212/144770530-ab7b993f-fade-417e-bec1-a544bf70188f.png">
<img width="781" alt="Screenshot 2021-12-06 at 01 27 57" src="https://user-images.githubusercontent.com/10616212/144770559-08c26399-92fc-4160-81a7-181ccf9b4b61.png">
[Municipalities, Sweden.csv](https://github.com/biolab/orange3/files/7657129/Municipalities.Sweden.csv)
[AreaPopulationScatterPlot.zip](https://github.com/biolab/orange3/files/7657130/AreaPopulationScatterPlot.zip)



Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/owscatterplot.py b/Orange/widgets/visualize/owscatterplot.py
--- a/Orange/widgets/visualize/owscatterplot.py
+++ b/Orange/widgets/visualize/owscatterplot.py
@@ -244,17 +244,12 @@ def _regression_line(x, y, color, width, style=Qt.SolidLine):
         slope, intercept, rvalue, _, _ = linregress(x, y)
         angle = np.degrees(np.arctan(slope))
         start_y = min_x * slope + intercept
-        rotate = 135 < angle % 360 < 315
-        l_opts = dict(color=color, position=abs(rotate - 0.85),
+        l_opts = dict(color=color, position=0.85,
                       rotateAxis=(1, 0), movable=True)
-        reg_line_item = pg.InfiniteLine(
+        return pg.InfiniteLine(
             pos=QPointF(min_x, start_y), angle=angle,
             pen=pg.mkPen(color=color, width=width, style=style),
             label=f"r = {rvalue:.2f}", labelOpts=l_opts)
-        if rotate:
-            reg_line_item.label.angle = 180
-            reg_line_item.label.updateTransform()
-        return reg_line_item
 
     def _add_line(self, x, y, color):
         width = self.parameter_setter.reg_line_settings[Updater.WIDTH_LABEL]


Test patch: