本文整理汇总了Python中PyQt4.Qwt5.QwtPlot.setCanvasBackground方法的典型用法代码示例。如果您正苦于以下问题:Python QwtPlot.setCanvasBackground方法的具体用法?Python QwtPlot.setCanvasBackground怎么用?Python QwtPlot.setCanvasBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qwt5.QwtPlot
的用法示例。
在下文中一共展示了QwtPlot.setCanvasBackground方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_plot
# 需要导入模块: from PyQt4.Qwt5 import QwtPlot [as 别名]
# 或者: from PyQt4.Qwt5.QwtPlot import setCanvasBackground [as 别名]
def add_plot(self, name, units):
# legend
legend = QwtLegend()
legend.setFrameStyle(Qt.QFrame.Box | Qt.QFrame.Sunken)
legend.setItemMode(QwtLegend.ClickableItem)
# plot
plot = QwtPlot(self)
plot.setTitle(name.upper())
plot.setObjectName(name)
plot.setCanvasBackground(Qt.Qt.white)
plot.setAxisTitle(QwtPlot.xBottom, "time [s]")
plot.insertLegend(legend, QwtPlot.RightLegend)
plot.time = deque(maxlen=MAX_LENGTH)
plot.data = []
plot.curves = []
for i, unit in enumerate(units):
position = QwtPlot.yLeft if i == 0 else QwtPlot.yRight
curve = QwtPlotCurve(LEGENDS[unit])
curve.setPen(Qt.QPen(self.next_color(), 2))
curve.setYAxis(position)
curve.attach(plot)
plot.enableAxis(position)
plot.setAxisTitle(position, unit)
plot.curves.append(curve)
plot.data.append(deque(maxlen=MAX_LENGTH))
self.vertical_layout.addWidget(plot)
self._plots[name] = plot
示例2: ImageControlDialog
# 需要导入模块: from PyQt4.Qwt5 import QwtPlot [as 别名]
# 或者: from PyQt4.Qwt5.QwtPlot import setCanvasBackground [as 别名]
#.........这里部分代码省略.........
self.line = TiggerPlotCurve()
self.color = color = color if isinstance(color, QColor) else QColor(color)
self.line.setPen(QPen(color, linewidth, linestyle))
self.marker = TiggerPlotMarker()
self.marker.setLabelAlignment(align)
try:
self.marker.setSpacing(spacing)
except AttributeError:
pass
self.setText(label)
self.line.setZ(z)
self.marker.setZ(zlabel if zlabel is not None else z)
# set axes -- using yRight, since that is the "markup" z-axis
self.line.setAxis(QwtPlot.xBottom, yaxis)
self.marker.setAxis(QwtPlot.xBottom, yaxis)
# attach to plot
self.line.attach(plot)
self.marker.attach(plot)
def show(self):
self.line.show()
self.marker.show()
def hide(self):
self.line.hide()
self.marker.hide()
def setText(self, text):
label = QwtText(text)
label.setColor(self.color)
self.marker.setLabel(label)
def _setupHistogramPlot(self):
self._histplot.setCanvasBackground(QColor("lightgray"))
self._histplot.setAxisFont(QwtPlot.yLeft, QApplication.font())
self._histplot.setAxisFont(QwtPlot.xBottom, QApplication.font())
# add histogram curves
self._histcurve1 = TiggerPlotCurve()
self._histcurve2 = TiggerPlotCurve()
self._histcurve1.setStyle(QwtPlotCurve.Steps)
self._histcurve2.setStyle(QwtPlotCurve.Steps)
self._histcurve1.setPen(QPen(Qt.NoPen))
self._histcurve1.setBrush(QBrush(QColor("slategrey")))
pen = QPen(QColor("red"))
pen.setWidth(1)
self._histcurve2.setPen(pen)
self._histcurve1.setZ(0)
self._histcurve2.setZ(100)
# self._histcurve1.attach(self._histplot)
self._histcurve2.attach(self._histplot)
# add maxbin and half-max curves
self._line_0 = self.HistogramLineMarker(self._histplot, color="grey50", linestyle=Qt.SolidLine,
align=Qt.AlignTop | Qt.AlignLeft, z=90)
self._line_mean = self.HistogramLineMarker(self._histplot, color="black", linestyle=Qt.SolidLine,
align=Qt.AlignBottom | Qt.AlignRight, z=91,
label="mean", zlabel=151)
self._line_std = self.HistogramLineMarker(self._histplot, color="black", linestyle=Qt.SolidLine,
align=Qt.AlignTop | Qt.AlignRight, z=91,
label="std", zlabel=151)
sym = QwtSymbol()
sym.setStyle(QwtSymbol.VLine)
sym.setSize(8)
self._line_std.line.setSymbol(sym)
self._line_maxbin = self.HistogramLineMarker(self._histplot, color="green", linestyle=Qt.DotLine,
align=Qt.AlignTop | Qt.AlignRight, z=92,
label="max bin", zlabel=150)
示例3: qwtchart
# 需要导入模块: from PyQt4.Qwt5 import QwtPlot [as 别名]
# 或者: from PyQt4.Qwt5.QwtPlot import setCanvasBackground [as 别名]
class qwtchart(chart):
colours = {'red' : Qt.red,
'green' : Qt.green,
'blue' : Qt.blue,
'yellow' : Qt.yellow,
'magenta': Qt.magenta,
'black' : Qt.black}
styles = {'-' : Qt.SolidLine,
'--': Qt.DashLine,
':' : Qt.DotLine,
'-.': Qt.DashDotLine}
def getPen(self, colour, style):
return QPen(self.colours[colour], 1, self.styles[style])
def __init__(self, spurset, fef, parent):
chart.__init__(self, spurset, fef, parent)
self.plot = QwtPlot(parent)
self.plot.setAxisScale(xaxis, self.spurset.RFmin,
self.spurset.RFmax)
self.plot.setAxisScale(yaxis, -self.spurset.dspan/2,
self.spurset.dspan/2)
self.plot.setCanvasBackground(Qt.white)
grid = QwtPlotGrid()
grid.setMajPen(QPen(Qt.black, 1, Qt.DotLine))
grid.attach(self.plot)
self.plot.insertLegend(QwtLegend(self.parent), QwtPlot.ExternalLegend)
# a picker to be used for the front-end filter parallelogram
self.picker = QwtPlotPicker(xaxis, yaxis,
QwtPicker.PointSelection,
QwtPlotPicker.NoRubberBand,
QwtPicker.AlwaysOff,
self.plot.canvas())
# gonna need this to implement ondrop()
self._mouseRelease = self.picker.widgetMouseReleaseEvent
self._picked_obj = None
self.picker.connect(self.picker, SIGNAL('appended(const QPoint&)'),
self.onpick)
self.picker.connect(self.picker, SIGNAL('moved(const QPoint&)'),
self.ondrag)
# all about the monkey-patching
self.picker.widgetMouseReleaseEvent = self.ondrop
def redraw(self):
xscale = self.plot.axisScaleDiv(xaxis)
yscale = self.plot.axisScaleDiv(yaxis)
#TODO check if it hurts to just set the scales every time, as in mpl
if (xscale.lowerBound() != self.spurset.RFmin or
xscale.upperBound() != self.spurset.RFmax):
self.plot.setAxisScale(xaxis, self.spurset.RFmin,
self.spurset.RFmax)
if (yscale.lowerBound() != -self.spurset.dspan/2 or
yscale.upperBound() != self.spurset.dspan/2):
self.plot.setAxisScale(yaxis, -self.spurset.dspan/2,
self.spurset.dspan/2)
self.plot.replot()
def mkline(self, xdata, ydata, style=('black','-'), title=''):
line = QwtPlotCurve(title)
if title is '':
# don't display it in the legend
# kind of ugly, that the title variable is doing double duty
line.setItemAttribute(QwtPlotItem.Legend, False)
pen = self.getPen(*style)
line.setPen(pen)
line.setRenderHint(QwtPlotItem.RenderAntialiased)
line.setData(xdata, ydata)
return line
def add_line(self, line):
line.attach(self.plot)
def del_line(self, line):
line.detach()
def legend(self):
return self.plot.legend()
def _xval(self, pos):
# from a QPoint referring to a pixel on the plot, find the x value
return self.plot.invTransform(xaxis, pos.x())
def _yval(self, pos):
# from a QPoint referring to a pixel on the plot, find the y value
return self.plot.invTransform(yaxis, pos.y())
def onpick(self, pos):
# for now, we only worry about picking the two vertical lines of the
# front-end filter parallelogram. Other clicks are no-ops.
if abs(pos.x() - self.plot.transform(xaxis, self.fef.start)) <= 10:
# TODO check pos.y() as well
self._picked_obj = self.fef.startline
self.pick(self.fef.startline, self._xval(pos), self._yval(pos))
elif abs(pos.x() - self.plot.transform(xaxis, self.fef.stop)) <= 10:
self._picked_obj = self.fef.stopline
#.........这里部分代码省略.........
示例4: Ui_MainWindow
# 需要导入模块: from PyQt4.Qwt5 import QwtPlot [as 别名]
# 或者: from PyQt4.Qwt5.QwtPlot import setCanvasBackground [as 别名]
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(847, 480)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.horizontalLayout_2 = QtGui.QHBoxLayout(self.centralwidget)
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
#Tworzenie zakładek
self.tabs = QtGui.QTabWidget(self.centralwidget)
#Główny wykre
self.plot = QwtPlot(self.centralwidget)
self.plot.setObjectName(_fromUtf8("plot"))
self.plot.setAxisScale(self.plot.yLeft, -20, 80)
self.plot.setAutoFillBackground(True)
#self.plot.setPalette(Qt.Qt.black)
self.plot.setCanvasBackground(Qt.Qt.black)
self.grid = QwtPlotGrid()
'''self.Yscale = QwtScaleDiv()
self.Yscale.setInterval(10)
self.Xscale = QwtScaleDiv()
self.Xscale.setInterval(10)
self.grid.setYDiv(self.YScale)
self.grid.setXDiv(self.Xscale)'''
self.grid.setMajPen(Qt.Qt.gray)
self.grid.attach(self.plot)
self.tabs.addTab(self.plot, "Spectrum")
self.curve = QwtPlotCurve('')
self.curve.setPen(Qt.Qt.yellow)
self.curve.attach(self.plot)
self.hold_curve = QwtPlotCurve('')
self.hold_curve.setPen(Qt.Qt.red)
self.peak_marker = QwtPlotMarker()
self.symbol = QwtSymbol(QwtSymbol.DTriangle, QtGui.QBrush(Qt.Qt.red), QtGui.QPen(Qt.Qt.red), QtCore.QSize(10,10))
self.peak_marker.setSymbol(self.symbol)
self.peak_marker.setLabelAlignment(Qt.Qt.AlignTop)
self.sybmol_2 = QwtSymbol(QwtSymbol.DTriangle, QtGui.QBrush(Qt.Qt.red), QtGui.QPen(Qt.Qt.white), QtCore.QSize(10,10))
self.marker_1 = QwtPlotMarker()
self.marker_1.setSymbol(self.sybmol_2)
self.marker_1.setLabelAlignment(Qt.Qt.AlignTop)
self.marker_2 = QwtPlotMarker()
self.marker_2.setSymbol(self.sybmol_2)
self.marker_2.setLabelAlignment(Qt.Qt.AlignTop)
self.marker_3 = QwtPlotMarker()
self.marker_3.setSymbol(self.sybmol_2)
self.marker_3.setLabelAlignment(Qt.Qt.AlignTop)
self.marker_4 = QwtPlotMarker()
self.marker_4.setSymbol(self.sybmol_2)
self.marker_4.setLabelAlignment(Qt.Qt.AlignTop)
self.delta_marker = QwtPlotMarker()
self.delta_marker.setSymbol(self.sybmol_2)
self.delta_marker.setLabelAlignment(Qt.Qt.AlignTop)
self.markers = [self.marker_1, self.marker_2, self.marker_3, self.marker_4]
self.save_curve_1 = QwtPlotCurve('')
self.save_curve_1.setPen(Qt.Qt.green)
self.save_curve_2 = QwtPlotCurve('')
self.save_curve_2.setPen(Qt.Qt.cyan)
self.save_curve_3 = QwtPlotCurve('')
self.save_curve_3.setPen(Qt.Qt.magenta)
self.saved_curves = [self.save_curve_1, self.save_curve_2, self.save_curve_3]
#Wykres waterfall
'''self.plot_2 = QwtPlot(self.centralwidget)
self.plot_2.setObjectName(_fromUtf8("plot_2"))
self.waterfall = QwtPlotSpectrogram()
self.waterfall.attach(self.plot_2)
self.colorMap = QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red)
self.scaleColors(80)
self.waterfall.setColorMap(self.colorMap)
#self.waterfallData = QwtRasterData()
#self.tabs.addTab(self.plot_2, "Waterfall")'''
self.verticalLayout.addWidget(self.tabs)
self.picker = QwtPlotPicker(QwtPlot.xBottom,
QwtPlot.yLeft,
QwtPicker.PointSelection | QwtPicker.DragSelection,
QwtPlotPicker.CrossRubberBand,
QwtPicker.AlwaysOn,
self.plot.canvas())
self.picker.setTrackerPen(Qt.Qt.white)
self.picker.setRubberBandPen(Qt.Qt.gray)
self.freqBox = QtGui.QGroupBox(self.centralwidget)
self.freqBox.setObjectName(_fromUtf8("freqBox"))
self.verticalLayout_3 = QtGui.QVBoxLayout(self.freqBox)
#.........这里部分代码省略.........