当前位置: 移动技术网 > IT编程>脚本编程>Python > PyQtGraph Basic Realization[2]

PyQtGraph Basic Realization[2]

2018年12月25日  | 移动技术网IT编程  | 我要评论

顶游资讯,梁祝吉他简谱,神之始皇

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)

  

second step

add lineregionitem to the first plot

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

  

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 . 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])

  

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 . 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 . 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

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网