4

I want to use the widget function addLine. In my case it is as following:

widget.addLine(x=None, y=0.8) #endless horizontal line

Now i want to change the color and width of this line, but i cannot find a fitting function.

Is there something available to do this?

Additional, is there a similar function to "add a circle" instead of a line?

hiro protagonist
  • 44,693
  • 14
  • 86
  • 111
Weevil
  • 87
  • 1
  • 3
  • 8

2 Answers2

12

Changing the color and width of the line is simple enough using the mkPen() function.

As you have not provided all of your code here is a simple demo:

import pyqtgraph as pg

y=[1,1,1,1,1]
pg.plot(y, pen=pg.mkPen('b', width=5))

Which draws a blue line with width 5. See the pyqtgraph documentation here

This would also work for the addLine() method you referenced in the question, e.g. widget.addLine(x=None, y=0.8, pen=mkPen('r', width=3))

As for your second question, looking at the pyqtgraph docs there doesn't appear to be a method that draws a circle.

enter image description here

Dror Cohen
  • 6,731
  • 5
  • 29
  • 32
smoggers
  • 3,154
  • 6
  • 26
  • 38
0

You can also set the parameters this way:

import pyqtgraph as pg

data = [...]   
pg.plot(data, pen={'color':'w', 'width':1.5})  
Henrique R
  • 94
  • 7