Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Scatter plot: Fix rotation of regression line label #5840

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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