欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PyQtGraph Basic Realization[2]

程序员文章站 2022-03-16 23:12:24
Profile Last Time We managed to add logic wave in the GraphicsLayoutWidget. Today We Try to add Curve for the GraphicsLayoutWidgets. First Step We Nee ......

profile

last time we managed to add logic wave in the graphicslayoutwidget. today we try to add curve for the graphicslayoutwidgets.

first step

we need to set the plotitem clickable as well

plt1.plot(list1,pen=pg.mkpen(color='#aa0000', width=1),name="red line")
curveplot.curve.setclickable(true)

  PyQtGraph Basic Realization[2]

second step

add lineregionitem to the first plot

        lr = pg.linearregionitem([1, 30], bounds=[0, 100], movable=true)
        plt1.additem(lr)

  PyQtGraph Basic Realization[2]

about the linearregionitem

__init__(values=(0, 1), orientation='vertical', brush=none, pen=none, hoverbrush=none, hoverpen=none, movable=true, bounds=none, span=(0, 1), swapmode='sort')
values a list of the positions of the lines in the region. these are not limits; limits can be set by specifying bounds.
orientation options are ‘vertical’ or ‘horizontal’, indicating the the default is ‘vertical’, indicating that the
brush defines the brush that fills the region. can be any arguments that are valid for mkbrush. default is transparent blue.
pen the pen to use when drawing the lines that bound the region.
hoverbrush the brush to use when the mouse is hovering over the region.
hoverpen the pen to use when the mouse is hovering over the region.
movable if true, the region and individual lines are movable by the user; if false, they are static.
bounds optional [min, max] bounding values for the region
span optional [min, max] giving the range over the view to draw the region. for example, with a vertical line, use span=(0.5, 1) to draw only on the top half of the view.
swapmode

sets the behavior of the region when the lines are moved such that their order reverses: * “block” means the user cannot drag one line past the other * “push” causes both lines to be moved if one would cross the other * “sort” means that lines may trade places, but the output of

getregion always gives the line positions in ascending order.
  • none means that no attempt is made to handle swapped line positions.

the default is “sort”.

 

third step

add single line

        line = pg.infiniteline(angle=90, movable=true)
        plt1.additem(line)
        line.setbounds([0, 200])

  PyQtGraph Basic Realization[2]

about the infiniteline

__init__(pos=none, angle=90, pen=none, movable=false, bounds=none, hoverpen=none, label=none, labelopts=none, span=(0, 1), markers=none, name=none)
arguments:  
pos position of the line. this can be a qpointf or a single value for vertical/horizontal lines.
angle angle of line in degrees. 0 is horizontal, 90 is vertical.
pen pen to use when drawing line. can be any arguments that are valid for mkpen. default pen is transparent yellow.
hoverpen pen to use when the mouse cursor hovers over the line. only used when movable=true.
movable if true, the line can be dragged to a new position by the user.
bounds optional [min, max] bounding values. bounds are only valid if the line is vertical or horizontal.
hoverpen pen to use when drawing line when hovering over it. can be any arguments that are valid for mkpen. default pen is red.
label text to be displayed in a label attached to the line, or none to show no label (default is none). may optionally include formatting strings to display the line value.
labelopts a dict of keyword arguments to use when constructing the text label. see inflinelabel.
span optional tuple (min, max) giving the range over the view to draw the line. for example, with a vertical line, use span=(0.5, 1) to draw only on the top half of the view.
markers list of (marker, position, size) tuples, one per marker to display on the line. see the addmarker method.
name name of the item