Python pyqtgraph.mkBrush() Examples
The following are 30
code examples of pyqtgraph.mkBrush().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyqtgraph
, or try the search function
.
Example #1
Source File: uiChanlunWidget.py From chanlun with MIT License | 7 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='w', width=0.4)) # 0.4 means w*2 a = pg.AxisItem('bottom', pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True) a.setFixedWidth(1) a.setWidth(1) a.setLabel(show=True) a.setGrid(grid=True) labelStyle = {'color': '#FFF', 'font-size': '14pt'} a.setLabel('label text', units='V', **labelStyle) # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) pg.setConfigOption('leftButtonPan', False) p.end()
Example #2
Source File: plots.py From autopilot with Mozilla Public License 2.0 | 6 votes |
def __init__(self, winsize=10, **kwargs): # type: (int) -> None """ Args: winsize (int): number of trials in the past to take a rolling mean of """ super(Roll_Mean, self).__init__() self.winsize = winsize self.setFillLevel(0.5) self.series = pd.Series() self.brush = pg.mkBrush((0,0,0,100)) self.setBrush(self.brush)
Example #3
Source File: reggui.py From suite2p with GNU General Public License v3.0 | 6 votes |
def cell_chosen(self): if self.Floaded: self.cell_mask() self.ROIedit.setText(str(self.ichosen)) rgb = np.array(self.colors[self.ichosen]) self.cellscatter.setData(self.xext, self.yext, pen=pg.mkPen(list(rgb)), brush=pg.mkBrush(list(rgb)), size=3) self.cellscatter_side.setData(self.xext, self.yext, pen=pg.mkPen(list(rgb)), brush=pg.mkBrush(list(rgb)), size=3) if self.ichosen >= len(self.stat): self.ichosen = len(self.stat) - 1 self.cell_mask() self.ft = self.Fcell[self.ichosen,:] self.plot_trace() self.p2.setXLink('plot_shift') self.jump_to_frame() self.show()
Example #4
Source File: candle_demo.py From Python-CTPAPI with MIT License | 6 votes |
def __init__(self, manager: BarManager): """""" super().__init__() self._manager: BarManager = manager self._bar_picutures: Dict[int, QtGui.QPicture] = {} self._item_picuture: QtGui.QPicture = None self._up_pen: QtGui.QPen = pg.mkPen( color=UP_COLOR, width=PEN_WIDTH ) self._up_brush: QtGui.QBrush = pg.mkBrush(color=UP_COLOR) self._down_pen: QtGui.QPen = pg.mkPen( color=DOWN_COLOR, width=PEN_WIDTH ) self._down_brush: QtGui.QBrush = pg.mkBrush(color=DOWN_COLOR) self._rect_area: Tuple[float, float] = None # Very important! Only redraw the visible part and improve speed a lot. self.setFlag(self.ItemUsesExtendedStyleOption)
Example #5
Source File: uiBasicWidget.py From InplusTrader_Linux with MIT License | 6 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='r', width=0.4)) # 0.4 means w*2 # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) p.end()
Example #6
Source File: uiBasicWidget.py From InplusTrader_Linux with MIT License | 6 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='r', width=0.4)) # 0.4 means w*2 # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) p.end()
Example #7
Source File: go.py From diyECG-1opAmp with MIT License | 6 votes |
def __init__(self, parent=None): pyqtgraph.setConfigOption('background', 'w') #before loading widget super(ExampleApp, self).__init__(parent) self.setupUi(self) self.grECG.plotItem.showGrid(True, True, 0.7) self.btnSave.clicked.connect(self.saveFig) self.btnSite.clicked.connect(self.website) stamp="DIY ECG by Scott Harden" self.stamp = pyqtgraph.TextItem(stamp,anchor=(-.01,1),color=(150,150,150), fill=pyqtgraph.mkBrush('w')) self.ear = swhear.Ear(chunk=int(100)) # determines refresh rate # optionally you can manually set the audio input device to use like this: # self.ear = swhear.Ear(chunk=int(100), device=5) # use audio input device 5 if len(self.ear.valid_input_devices()): self.ear.stream_start() self.lblDevice.setText(self.ear.msg) self.update()
Example #8
Source File: uiChanlunWidget.py From chanlun with MIT License | 6 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='w', width=0.4)) # 0.4 means w*2 # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (n, t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(n, min), QtCore.QPointF(n, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(n-w, open, w*2, close-open)) pg.setConfigOption('leftButtonPan', False) p.end()
Example #9
Source File: uiBasicWidget修改.py From chanlun with MIT License | 6 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='w', width=0.4)) # 0.4 means w*2 # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) p.end()
Example #10
Source File: __init__.py From finplot with MIT License | 6 votes |
def generate_picture(self, boundingRect): w = self.candle_width w2 = w * 0.5 left,right = boundingRect.left(), boundingRect.right() p = self.painter p.begin(self.picture) df,origlen = self.datasrc.rows(5, left, right, yscale=self.ax.vb.yscale) drawing_many_shadows = self.draw_shadow and origlen > lod_candles*2//3 for shadow,frame,body,df_rows in self.colorfunc(self, self.datasrc, df): idxs = df_rows.index rows = df_rows.values if self.x_offset: idxs += self.x_offset if self.draw_shadow: p.setPen(pg.mkPen(shadow)) for x,(t,open,close,high,low) in zip(idxs, rows): if high > low: p.drawLine(QtCore.QPointF(x, low), QtCore.QPointF(x, high)) if self.draw_body and not drawing_many_shadows: # settle with only drawing shadows if too much detail p.setPen(pg.mkPen(frame)) p.setBrush(pg.mkBrush(body)) for x,(t,open,close,high,low) in zip(idxs, rows): p.drawRect(QtCore.QRectF(x-w2, open, w, close-open)) p.end()
Example #11
Source File: demoUi.py From chanlun with MIT License | 6 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='w', width=0.4)) # 0.4 means w*2 # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) p.end()
Example #12
Source File: graphtab.py From equant with GNU General Public License v2.0 | 5 votes |
def generatePicture(self, datas=None): self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen('w')) w = 0.4 for i, data in enumerate(datas): if data >= 0: p.setPen(pg.mkPen('r')) p.setBrush(pg.mkBrush('r')) else: p.setPen(pg.mkPen('g')) p.setBrush(pg.mkBrush('g')) p.drawRect(QtCore.QRectF(i-w, 0, w * 2, data)) p.end()
Example #13
Source File: plots.py From autopilot with Mozilla Public License 2.0 | 5 votes |
def __init__(self, **kwargs): super(Shaded, self).__init__() #self.dur = float(dur) # duration of time to display points in seconds self.setFillLevel(0) self.series = pd.Series() self.getBoundingParents() self.brush = pg.mkBrush((0,0,0,100)) self.setBrush(self.brush) self.max_num = 0
Example #14
Source File: charts.py From Quantdom with Apache License 2.0 | 5 votes |
def paint(self, p, *args): p.setRenderHint(p.Antialiasing) if isinstance(self.item, tuple): positive = self.item[0].opts negative = self.item[1].opts p.setPen(pg.mkPen(positive['pen'])) p.setBrush(pg.mkBrush(positive['brush'])) p.drawPolygon( QtGui.QPolygonF( [ QtCore.QPointF(0, 0), QtCore.QPointF(18, 0), QtCore.QPointF(18, 18), ] ) ) p.setPen(pg.mkPen(negative['pen'])) p.setBrush(pg.mkBrush(negative['brush'])) p.drawPolygon( QtGui.QPolygonF( [ QtCore.QPointF(0, 0), QtCore.QPointF(0, 18), QtCore.QPointF(18, 18), ] ) ) else: opts = self.item.opts p.setPen(pg.mkPen(opts['pen'])) p.drawRect(0, 10, 18, 0.5)
Example #15
Source File: OWAnnotateProjection.py From orange3-bioinformatics with GNU General Public License v3.0 | 5 votes |
def __init__(self, view_box, x, y, text, tooltip): bg_color = QColor(Qt.white) bg_color.setAlpha(200) color = QColor(Qt.black) super().__init__(text, pg.mkColor(color), fill=pg.mkBrush(bg_color)) self._x = x self._y = y self._view_box = view_box self._view_box.sigStateChanged.connect(self.center) self.textItem.setToolTip(tooltip) self.setPos(x, y) self.center()
Example #16
Source File: OWAnnotateProjection.py From orange3-bioinformatics with GNU General Public License v3.0 | 5 votes |
def update_reference_coordinates(self): points = self.master.get_coordinates_reference_data() if points is None: return if self.ref_scatterplot_item is None: color = pg.mkColor(200, 200, 200) pen, brush = pg.mkPen(color=color), pg.mkBrush(color=color) size = OWScatterPlotBase.MinShapeSize + 3 self.ref_scatterplot_item = pg.ScatterPlotItem(x=points[0], y=points[1], pen=pen, brush=brush, size=size) self.plot_widget.addItem(self.ref_scatterplot_item) else: self.ref_scatterplot_item.setData(x=points[0], y=points[1])
Example #17
Source File: OWDifferentialExpression.py From orange3-bioinformatics with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent=None, **kwargs): pg.PlotWidget.__init__(self, parent, **kwargs) self.getAxis("bottom").setLabel("Score") self.getAxis("left").setLabel("Counts") self.__data = None self.__histcurve = None self.__mode = Histogram.NoSelection self.__min = 0 self.__max = 0 def makeline(pos): pen = QPen(Qt.darkGray, 1) pen.setCosmetic(True) line = InfiniteLine(angle=90, pos=pos, pen=pen, movable=True) line.setCursor(Qt.SizeHorCursor) return line self.__cuthigh = makeline(self.__max) self.__cuthigh.sigPositionChanged.connect(self.__on_cuthigh_changed) self.__cuthigh.sigPositionChangeFinished.connect(self.selectionEdited) self.__cutlow = makeline(self.__min) self.__cutlow.sigPositionChanged.connect(self.__on_cutlow_changed) self.__cutlow.sigPositionChangeFinished.connect(self.selectionEdited) brush = pg.mkBrush((200, 200, 200, 180)) self.__taillow = pg.PlotCurveItem(fillLevel=0, brush=brush, pen=QPen(Qt.NoPen)) self.__taillow.setVisible(False) self.__tailhigh = pg.PlotCurveItem(fillLevel=0, brush=brush, pen=QPen(Qt.NoPen)) self.__tailhigh.setVisible(False)
Example #18
Source File: customGraphicsItem.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen('w')) w = (self.data[1][0] - self.data[0][0]) / 3. for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('r')) else: p.setBrush(pg.mkBrush('g')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) p.end()
Example #19
Source File: __init__.py From finplot with MIT License | 5 votes |
def paint(self, p, *args): p.setPen(pg.mkPen(self.border_color)) p.setBrush(pg.mkBrush(self.fill_color)) p.drawRect(self.boundingRect())
Example #20
Source File: __init__.py From finplot with MIT License | 5 votes |
def plot(x, y=None, color=None, width=1, ax=None, style=None, legend=None, zoomscale=True): ax = _create_plot(ax=ax, maximize=False) used_color = _get_color(ax, style, color) datasrc = _create_datasrc(ax, x, y) if not zoomscale: datasrc.scale_cols = [] _set_datasrc(ax, datasrc) if legend is not None and ax.legend is None: ax.legend = FinLegendItem(border_color=legend_border_color, fill_color=legend_fill_color, size=None, offset=(3,2)) ax.legend.setParentItem(ax.vb) y = datasrc.y / ax.vb.yscale.scalef if style is None or style=='-': connect_dots = 'finite' # same as matplotlib; use datasrc.standalone=True if you want to keep separate intervals on a plot item = ax.plot(datasrc.index, y, pen=pg.mkPen(used_color, width=width), name=legend, connect=connect_dots) else: symbol = {'v':'t', '^':'t1', '>':'t2', '<':'t3'}.get(style, style) # translate some similar styles ser = y.loc[y.notnull()] item = ax.plot(ser.index, ser.values, pen=None, symbol=symbol, symbolPen=None, symbolSize=10, symbolBrush=pg.mkBrush(used_color), name=legend) item.scatter._dopaint = item.scatter.paint item.scatter.paint = partial(_paint_scatter, item.scatter) # optimize (when having large number of points) by ignoring scatter click detection _dummy_mouse_click = lambda ev: 0 item.scatter.mouseClickEvent = _dummy_mouse_click item.opts['handed_color'] = color item.ax = ax item.datasrc = datasrc _update_significants(ax, datasrc, force=False) item.update_data = partial(_update_data, None, item) if ax.legend is not None: for _,label in ax.legend.items: label.setAttr('justify', 'left') label.setText(label.text, color=legend_text_color) return item
Example #21
Source File: __init__.py From finplot with MIT License | 5 votes |
def fill_between(plot0, plot1, color=None): used_color = brighten(_get_color(plot0.ax, None, color), 1.3) item = pg.FillBetweenItem(plot0, plot1, brush=pg.mkBrush(used_color)) item.ax = plot0.ax plot0.ax.addItem(item) return item
Example #22
Source File: __init__.py From finplot with MIT License | 5 votes |
def add_band(y0, y1, color=band_color, ax=None): ax = _create_plot(ax=ax, maximize=False) lr = pg.LinearRegionItem([y0,y1], orientation=pg.LinearRegionItem.Horizontal, brush=pg.mkBrush(color), movable=False) lr.lines[0].setPen(pg.mkPen(None)) lr.lines[1].setPen(pg.mkPen(None)) lr.setZValue(-10) ax.addItem(lr)
Example #23
Source File: test_ScatterPlotItem.py From soapy with GNU General Public License v3.0 | 5 votes |
def test_init_spots(): plot = pg.PlotWidget() # set view range equal to its bounding rect. # This causes plots to look the same regardless of pxMode. plot.setRange(rect=plot.boundingRect()) spots = [ {'x': 0, 'y': 1}, {'pos': (1, 2), 'pen': None, 'brush': None, 'data': 'zzz'}, ] s = pg.ScatterPlotItem(spots=spots) # Check we can display without errors plot.addItem(s) app.processEvents() plot.clear() # check data is correct spots = s.points() defPen = pg.mkPen(pg.getConfigOption('foreground')) assert spots[0].pos().x() == 0 assert spots[0].pos().y() == 1 assert spots[0].pen() == defPen assert spots[0].data() is None assert spots[1].pos().x() == 1 assert spots[1].pos().y() == 2 assert spots[1].pen() == pg.mkPen(None) assert spots[1].brush() == pg.mkBrush(None) assert spots[1].data() == 'zzz'
Example #24
Source File: AttributeCharts.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def drawScatterplot(self, xvalues, xmin, xmax, yvalues, ymin, ymax, slope, intercept, ids, symbols=None): # plot the chart if has_pyqtgraph: self.scatter = pg.ScatterPlotItem() self.plot.clear() # each point takes the colour of the map if symbols: points = [] for i, id in enumerate(ids): x = xvalues[i] y = yvalues[i] symb = symbols[i] points.append({'pos': (x,y), 'data': id, 'size': 3, 'pen': pg.mkPen(None), 'brush': symb}) self.scatter.addPoints(points) else: self.scatter.addPoints(x=xvalues, y=yvalues, data=ids, size=3, pen=pg.mkPen(None), brush=pg.mkBrush(235, 235, 235, 255)) # selection by direct click self.scatter.sigClicked.connect(self.changedScatterplotSelection) self.plot.addItem(self.scatter) # add the regression line self.regress_line = pg.InfiniteLine() self.regress_line.setAngle(atan(slope/1) * 180 / 3.1459) self.regress_line.setValue((0,intercept)) self.regress_line.setPen(color='b', width=1) if self.show_lines: self.plot.addItem(self.regress_line) # newfeature: add the selection tool #self.roi = pg.PolyLineROI([[xmin, ymin],[xmax, ymin],[xmax, ymax],[xmin, ymax]], closed=True) #self.roi.sigRegionChangeFinished.connect(self.changedScatterPlotSelection) #self.plot.addItem(self.roi) #self.plot.disableAutoRange('xy') # allow selection of items in chart and selecting them on the map
Example #25
Source File: AttributeCharts.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def setScatterplotSelection(self, xvalues, yvalues, ids): if has_pyqtgraph: #if not self.just_selected: self.clearScatterplotSelection() if len(ids) > 0: self.scatter_selection = [fid for fid in ids] self.selected_points = pg.ScatterPlotItem() self.selected_points.addPoints(x=xvalues, y=yvalues, data=ids, size=3, pen=pg.mkPen('r', width=1), brush=pg.mkBrush(235, 0, 0, 255)) self.plot.addItem(self.selected_points) self.just_selected = False
Example #26
Source File: chain.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def makeGraph(self): #g1 = pg.GraphItem(pos=self.pos, adj=self.links[self.rope], pen=0.2, symbol=None) brushes = np.where(self.fixed, pg.mkBrush(0,0,0,255), pg.mkBrush(50,50,200,255)) g2 = pg.GraphItem(pos=self.pos, adj=self.links[self.push & self.pull], pen=0.5, brush=brushes, symbol='o', size=(self.mass**0.33), pxMode=False) p = pg.ItemGroup() #p.addItem(g1) p.addItem(g2) return p
Example #27
Source File: pyoptic.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def __init__(self, pen=None, brush=None, **opts): """ Arguments for each surface are: x1,x2 - position of center of _physical surface_ r1,r2 - radius of curvature d1,d2 - diameter of optic """ defaults = dict(x1=-2, r1=100, d1=25.4, x2=2, r2=100, d2=25.4) defaults.update(opts) ParamObj.__init__(self) self.surfaces = [CircleSurface(defaults['r1'], defaults['d1']), CircleSurface(-defaults['r2'], defaults['d2'])] pg.GraphicsObject.__init__(self) for s in self.surfaces: s.setParentItem(self) if pen is None: self.pen = pg.mkPen((220,220,255,200), width=1, cosmetic=True) else: self.pen = pg.mkPen(pen) if brush is None: self.brush = pg.mkBrush((230, 230, 255, 30)) else: self.brush = pg.mkBrush(brush) self.setParams(**defaults)
Example #28
Source File: relativity.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def __init__(self, x0=0.0, y0=0.0, m0=1.0, v0=0.0, t0=0.0, color=None, prog=None, size=0.5): Clock.nClocks += 1 self.pen = pg.mkPen(color) self.brush = pg.mkBrush(color) self.y0 = y0 self.x0 = x0 self.v0 = v0 self.m0 = m0 self.t0 = t0 self.prog = prog self.size = size
Example #29
Source File: relativity.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def __init__(self, clock): pg.ItemGroup.__init__(self) self.size = clock.size self.item = QtGui.QGraphicsEllipseItem(QtCore.QRectF(0, 0, self.size, self.size)) self.item.translate(-self.size*0.5, -self.size*0.5) self.item.setPen(pg.mkPen(100,100,100)) self.item.setBrush(clock.brush) self.hand = QtGui.QGraphicsLineItem(0, 0, 0, self.size*0.5) self.hand.setPen(pg.mkPen('w')) self.hand.setZValue(10) self.flare = QtGui.QGraphicsPolygonItem(QtGui.QPolygonF([ QtCore.QPointF(0, -self.size*0.25), QtCore.QPointF(0, self.size*0.25), QtCore.QPointF(self.size*1.5, 0), QtCore.QPointF(0, -self.size*0.25), ])) self.flare.setPen(pg.mkPen('y')) self.flare.setBrush(pg.mkBrush(255,150,0)) self.flare.setZValue(-10) self.addItem(self.hand) self.addItem(self.item) self.addItem(self.flare) self.clock = clock self.i = 1 self._spaceline = None
Example #30
Source File: uiKLine.py From uiKLine with MIT License | 5 votes |
def __init__(self, data): """初始化""" pg.GraphicsObject.__init__(self) # 数据格式: [ (time, open, close, low, high),...] self.data = data # 只重画部分图形,大大提高界面更新速度 self.rect = None self.picture = None self.setFlag(self.ItemUsesExtendedStyleOption) # 画笔和画刷 w = 0.4 self.offset = 0 self.low = 0 self.high = 1 self.picture = QtGui.QPicture() self.pictures = [] self.gPen = pg.mkPen(color=(1, 255, 7, 255), width=w*2) self.gBrush = pg.mkBrush((1, 255, 7, 255)) self.bPen = pg.mkPen(color=(0, 240, 240, 255), width=w*2) self.bBrush = pg.mkBrush((0, 240, 240, 255)) self.rPen = pg.mkPen(color=(255, 60, 60, 255), width=w*2) self.rBrush = pg.mkBrush((255, 60, 60, 255)) self.rBrush.setStyle(Qt.NoBrush) # 刷新K线 self.generatePicture(self.data) # 画K线 #----------------------------------------------------------------------