Skip to content

PR #2011 + anti-aliasing enabled leads to line artifacts #2178

@swvanbuuren

Description

@swvanbuuren

Short description

PR #2011 introduced an optimized way to plot thick lines. However, when anti-aliasing is enabled, this
leads to line artifacts.

Code to reproduce

import pyqtgraph as pg
pg.setConfigOptions(antialias=True)
pg.setConfigOption('background', 'w')
pg.setConfigOption('foreground', 'k')
import pyqtgraph.Qt.QtWidgets as QtWidgets
import numpy as np

win = pg.GraphicsLayoutWidget(show=True)
win.resize(800,350)
win.setWindowTitle('pyqtgraph example: #2011 test')
plt1 = win.addPlot(title='With anti-aliasing and alpha = 1')
plt2 = win.addPlot(title='With anti-aliasing and alpha != 1')

x = np.linspace(0, 2*np.pi, 25)
y = np.sin(x)

WIDTH = 4.0
color = (0, 113, 188)
pen = pg.mkPen(color + (255,), width=WIDTH)
pen_alpha = pg.mkPen(color + (254,), width=WIDTH)

plt1.plot(x, y, pen=pen)
plt2.plot(x, y, pen=pen_alpha)

QtWidgets.QApplication.instance().exec_()

Expected behavior

Fallback to the old drawing method whenever anti-aliasing is enabled (just as is the case if alpha < 1).

Real behavior

Line artifacts are seen for thicker lines.

Tested environment(s)

  • PyQtGraph version: commit Id 8436457 and newer
  • Qt Python binding: PySide2 5.15.1 Qt 5.15.1
  • Python version: 3.8.10
  • NumPy version: 1.19.2
  • Operating system: XUbuntu 20.04.2 LTS
  • Installation method: pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions