Skip to content

Commit

Permalink
Merge pull request #5840 from janezd/scatteplot-proper-labels
Browse files Browse the repository at this point in the history
[FIX] Scatter plot: Fix rotation of regression line label
  • Loading branch information
ajdapretnar authored Feb 18, 2022
2 parents 10ecebf + 4c34372 commit baef1d9
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Orange/widgets/visualize/owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit baef1d9

Please sign in to comment.