本文整理汇总了Python中pyqtgraph.mkColor函数的典型用法代码示例。如果您正苦于以下问题:Python mkColor函数的具体用法?Python mkColor怎么用?Python mkColor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkColor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: change_to_trace
def change_to_trace(self, trace):
""" Set curTrace to TRACE. Update all the buttons/table_slice
and then highlight the proper row in the table_traces."""
# Deselecting the previous curTrace
if self.curTrace is not None:
index = -1
for row in range(self.table_traces.rowCount()):
item = self.table_traces.item(row, 0)
if str(item.text()) == self.curTrace.name():
index = row
if index != -1:
item = self.table_traces.item(index, 0)
item.setBackgroundColor(pqg.mkColor(255, 255, 255, 255))
# Selecting the current trace
index = -1
for row in range(self.table_traces.rowCount()):
item = self.table_traces.item(row, 0)
if str(item.text()) == trace.name():
index = row
if index != -1:
item = self.table_traces.item(index, 0)
item.setBackgroundColor(pqg.mkColor(0, 200, 200, 200))
self.curTrace = trace
trace.update_slice_table(self.table_slice)
self.sync_buttons()
示例2: __init__
def __init__(self, layout):
if not isinstance(layout, pg.GraphicsLayoutWidget):
raise ValueError("layout must be instance of pyqtgraph.GraphicsLayoutWidget")
self.layout = layout
self.main_curve = True
self.main_color = pg.mkColor("y")
self.persistence = False
self.persistence_length = 5
self.persistence_decay = "exponential"
self.persistence_color = pg.mkColor("g")
self.peak_hold = False
self.peak_hold_color = pg.mkColor("r")
self.average = False
self.average_color = pg.mkColor("c")
self.smooth = False
self.smooth_length = 11
self.smooth_window = "hanning"
self.counter = 0
self.peak_hold_data = None
self.average_data = None
self.persistence_data = None
self.persistence_curves = None
self.create_plot()
示例3: select_image
def select_image(self):
'''
Select current image sequence to begin DIC setup.
'''
self.openFolder.setEnabled(False)
self.naprejButton.setEnabled(False)
self.nazajButton.setEnabled(True)
self.calibButton.setEnabled(True)
self.beginButton.setEnabled(True)
self.mode_selection.setEnabled(True)
pathtext = '<b>Selected directory:</b><br>' + self.dir_path
pathtext += '<br>(initial image - specify the region of interest)'
self.pathlabel.setText(pathtext)
self.default_calibration()
self.initialImage = tools.get_sequence(self.mraw_path, file_shape=(self.N_images, self.h, self.w), nmax=1).T
self.imw.setImage(self.initialImage)
self.imw.ui.histogram.hide()
# Add ROI widget to the view:
image_shape = self.initialImage.shape
roi_pos = (image_shape[0]//2 - self.min_roi_size[0], image_shape[1]//2 - self.min_roi_size[1])
ch_roi_pos = tools.get_roi_center(roi_pos, self.initial_roi_size)
roi_bound = QtCore.QRectF(0, 0, image_shape[0], image_shape[1])
self.imw.roi = pg.ROI(roi_pos, self.initial_roi_size, maxBounds=roi_bound, scaleSnap=True, translateSnap=True)
self.imw.CHroi = DotROI(ch_roi_pos, size=1, movable=False)
self.imw.view.addItem(self.imw.roi)
self.imw.view.addItem(self.imw.CHroi)
self.imw.roi.sigRegionChanged.connect(self.imw.roiChanged)
self.imw.roi.sigRegionChanged.connect(self.moving_roi)
self.imw.roi.sigRegionChangeFinished.connect(self.update_roi_position)
self.imw.roi.addScaleHandle(pos=(1, 1), center=(0.5, 0.5))
self.imw.roi.setPen(pg.mkPen(color=pg.mkColor('00FF6F'), width=2))
self.imw.CHroi.setPen(pg.mkPen(color=pg.mkColor('FF0000'), width=2))
self.roi_set = True
示例4: pulseOverlayPens
def pulseOverlayPens(self):
# TGCA
# Color ggrr
# Ampl 2121
return [ mkPen(mkColor("g"), width=4),
mkPen(mkColor("g"), width=2),
mkPen(mkColor("r"), width=4),
mkPen(mkColor("r"), width=2) ]
示例5: show_scatter
def show_scatter(self):
spots = [dict(pos=pos,
data=rules,
brush=pg.mkColor(np.clip(1/len(rules), 0, .8)),
pen=pg.mkColor(np.clip(1/len(rules), .1, .8) - .1))
for pos, rules in self.scatter_agg.items()]
self.scatter.scatter.setData(spots=spots)
self.scatter.plot.setRange(xRange=(0, 1), yRange=(0, 1))
self.scatter.show()
示例6: update_state
def update_state(self, state):
try:
ve = state[self.key + '.V']
vm = state['.'.join(self.key.split('.')[:-1]) + '.V']
self.setVisible(True)
except KeyError:
self.setVisible(False)
return
y = self.voltage.boundingRect().top()
grad = QtGui.QLinearGradient(QtCore.QPointF(0, y), QtCore.QPointF(0, y+25))
grad.setColorAt(0, pg.mkColor(v_color(vm)))
grad.setColorAt(1, pg.mkColor(v_color(ve)))
self.voltage.setBrush(QtGui.QBrush(grad))
self.current.update_state(state)
示例7: overlay
def overlay(self):
alpha = 256.0/(len(self.exp)-len(self.bad))
color = pg.mkColor(0,0,0,alpha)
self.ui.grafo.clear()
for i in xrange(len(self.exp)):
if self.alignFlags[i] and self.exp[i].relevant:
self.ui.grafo.plot(self.exp[i][-1].z,self.exp[i][-1].f,pen=None,symbol='o',symbolSize = 2,symbolPen = color, symbolBrush = color)
示例8: _make_header_text
def _make_header_text(self, txt, rowcol, side, padding=5, font_size=None):
size = self.cell_size
if font_size is None:
font_size = size / 3.
small_font_size = font_size * 0.7
align = pg.QtCore.Qt.AlignLeft if side == 'top' else pg.QtCore.Qt.AlignRight
lines = str(txt).split('\n')
html = '<div style="line-height: 70%%">'
for i,line in enumerate(lines):
fs = font_size if i == 0 else small_font_size
if i > 0:
html += '<br>'
html += '<span style="font-size: %dpx;">%s</span>' % (fs, line)
html += '</div>'
item = pg.QtGui.QGraphicsTextItem("", parent=self)
item.setHtml(html)
item.setTextWidth(item.boundingRect().width())
doc = item.document()
opts = doc.defaultTextOption()
opts.setAlignment(align)
doc.setDefaultTextOption(opts)
if side == 'top':
item.rotate(-90)
br = item.mapRectToParent(item.boundingRect())
if side == 'top':
item.setPos(rowcol * size + size/2 - br.center().x(), -br.bottom() - padding)
elif side == 'left':
item.setPos(-br.right() - padding, rowcol * size + size/2. - br.center().y())
else:
raise ValueError("side must be top or left")
item.setDefaultTextColor(pg.mkColor(self.header_color))
item.setTextWidth(item.boundingRect().width()) # needed to enable text alignment
return item
示例9: processPoint
def processPoint(self,_in_point):
# Check if this point is close to another point (less than some dist)
i = 0
for point in self._drawnPoints:
if point.contains(_in_point):
self._dataPoints.pop(i)
self._polygon.remove(i)
self._view.removeItem(self._drawnPoints[i])
self._drawnPoints.pop(i)
# Refresh the path:
self._path = QtGui.QPainterPath()
self._path.addPolygon(self._polygon)
self._polyGraphicsItem.setPath(self._path)
return
i +=1
# Point wasn't popped, so add it to the list
self._dataPoints.append(_in_point)
r = QtGui.QGraphicsEllipseItem(_in_point.x()-1, _in_point.y()-10, 2,20)
r.setBrush(pg.mkColor((0,0,0)))
self._view.addItem(r)
self._drawnPoints.append(r)
# Refresh the polygon and then update the path
self._polygon.append(_in_point)
# self._polyGraphicsItem.setPolygon(self._polygon)
self._path = QtGui.QPainterPath()
self._path.addPolygon(self._polygon)
self._polyGraphicsItem.setPath(self._path)
示例10: setColor
def setColor(self, color):
if color != self._color:
self._color = color
self.colorChanged.emit()
# handles different color formats
try:
r,g,b,a = pg.colorTuple(self._color)
except:
r,g,b,a = pg.colorTuple(pg.mkColor(self._color))
if self._color:
self.setStyleSheet('background-color: rgba(%d,%d,%d,%d);' %(r,g,b,a))
self._color = pg.mkColor(self._color)
else:
self.setStyleSheet("")
示例11: __init__
def __init__(self, kv=15, initial_mode='eds'):
pg.PlotWidget.__init__(self,
viewBox=CustomViewBox(),
labels={'left': ['counts', 'cts']},
axisItems={'left': pg.AxisItem('left'),
'bottom': CustomAxisItem('bottom')},
background=BACKGROUND_COLOR)
#p1 the main plotItem/canvas
#p2 secondary viewbox for EDS preview lines
#p3 third viewbox for EDS marked lines
self.p1 = self.plotItem
self.p2 = pg.ViewBox()
self.p3 = pg.ViewBox()
self.p1.scene().addItem(self.p2)
self.p2.setXLink(self.p1)
self.p3.setXLink(self.p1)
self.p3.setYLink(self.p1)
self.bottom_axis = self.p1.axes['bottom']['item']
self.updateViews()
self.x_axis_mode = initial_mode
self.set_kv(kv)
self.p1.vb.sigResized.connect(self.updateViews)
self.prev_text_size = 12
self.prev_marker_pen = pg.mkPen((255,200,255, 180), width=2)
self.prev_text_color = pg.mkColor((200,200,200))
self.p1.setLimits(yMin=0)
self.p3.setLimits(yMin=0)
self.p2.setLimits(yMin=0)
self.p2.setYRange(0, 1)
self.set_xtal(8.75, 0.000144) # default to PET crystal
self.set_x_mode(self.x_axis_mode)
self.set_connections()
示例12: update_labels
def update_labels(self):
"""
Trigger an updaet of labels
The method calls `get_labels` which in turn calls the widget's
`get_label_data`. The obtained labels are shown if the corresponding
points are selected or if `label_only_selected` is `false`.
"""
for label in self.labels:
self.plot_widget.removeItem(label)
self.labels = []
if self.scatterplot_item is None \
or self.label_only_selected and self.selection is None:
return
labels = self.get_labels()
if labels is None:
return
black = pg.mkColor(0, 0, 0)
x, y = self.scatterplot_item.getData()
if self.label_only_selected:
selected = np.nonzero(self._filter_visible(self.selection))
labels = labels[selected]
x = x[selected]
y = y[selected]
for label, xp, yp in zip(labels, x, y):
ti = TextItem(label, black)
ti.setPos(xp, yp)
self.plot_widget.addItem(ti)
self.labels.append(ti)
示例13: __init__
def __init__(self, parent=None):
QtGui.QSplitter.__init__(self, QtCore.Qt.Horizontal)
self.ctrlPanel = QtGui.QSplitter(QtCore.Qt.Vertical)
self.addWidget(self.ctrlPanel)
self.fieldList = QtGui.QListWidget()
self.fieldList.setSelectionMode(self.fieldList.ExtendedSelection)
self.ptree = ptree.ParameterTree(showHeader=False)
self.filter = DataFilterParameter()
self.colorMap = ColorMapParameter()
self.params = ptree.Parameter.create(name="params", type="group", children=[self.filter, self.colorMap])
self.ptree.setParameters(self.params, showTop=False)
self.plot = PlotWidget()
self.ctrlPanel.addWidget(self.fieldList)
self.ctrlPanel.addWidget(self.ptree)
self.addWidget(self.plot)
bg = pg.mkColor(pg.getConfigOption("background"))
bg.setAlpha(150)
self.filterText = pg.TextItem(border=pg.getConfigOption("foreground"), color=bg)
self.filterText.setPos(60, 20)
self.filterText.setParentItem(self.plot.plotItem)
self.data = None
self.mouseOverField = None
self.scatterPlot = None
self.style = dict(pen=None, symbol="o")
self.fieldList.itemSelectionChanged.connect(self.fieldSelectionChanged)
self.filter.sigFilterChanged.connect(self.filterChanged)
self.colorMap.sigColorMapChanged.connect(self.updatePlot)
示例14: _symbolColor
def _symbolColor(pw, color=None, lineWidth=1, symbol='', symbolSize=3, fillLevel=None):
# color
color = _color(pw, color)
# line or symbol color
if lineWidth:
pen = pg.mkPen(color, width=lineWidth)
kwd = {'pen': pen}
else:
kwd = {'pen': None}
if symbol or symbolSize:
kwd['symbolBrush'] = color
kwd['symbolPen'] = color
# symbolPen is outline
# symbol
if symbol:
kwd['symbol'] = SYMBOLS[symbol]
if symbolSize:
kwd['symbolSize'] = symbolSize
# fill
if fillLevel is not None:
kwd['fillLevel'] = fillLevel
r, g, b, a = color.red(), color.green(), color.blue(), color.alpha()
if a == 255:
a = 50
else:
a //= 5
fillColor = pg.mkColor((r,g,b,a))
kwd['fillBrush'] = fillColor
return kwd
示例15: drawObjects
def drawObjects(self, view_manager):
geom = view_manager._geometry
# Just draw the vertex to start:
info = self._process.getData()
vertex = info.vertex()
for view in view_manager.getViewPorts():
self._drawnObjects.append([])
offset = geom.offset(view.plane())
vertexPoint = larutil.GeometryHelper.GetME().Point_3Dto2D(
vertex, view.plane())
# print "VertexPoint in plane {plane}: ({w},{t})".format(
# plane=view.plane(),
# w=vertexPoint.w,
# t=vertexPoint.t)
points = self.makeCross(vertexPoint.w/geom.wire2cm(),
(vertexPoint.t + offset )/geom.time2cm(),
shortDistX=0.05/geom.wire2cm(),
longDistX=1.0/geom.wire2cm(),
shortDistY=0.05/geom.time2cm(),
longDistY=1.0/geom.time2cm(),
)
thisPolyF = QtGui.QPolygonF(points)
thisPoly = QtGui.QGraphicsPolygonItem(thisPolyF)
thisPoly.setBrush(pg.mkColor((200,200,200,200)))
self._drawnObjects[view.plane()].append(thisPoly)
view._view.addItem(thisPoly)