本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setAutoFillBackground方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.setAutoFillBackground方法的具体用法?Python FigureCanvasQTAgg.setAutoFillBackground怎么用?Python FigureCanvasQTAgg.setAutoFillBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.setAutoFillBackground方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ValueWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setAutoFillBackground [as 别名]
class ValueWidget(QWidget, Ui_Widget):
def __init__(self, iface):
self.hasqwt=hasqwt
self.hasmpl=hasmpl
self.layerMap=dict()
self.statsChecked=False
self.ymin=0
self.ymax=250
self.isActive=False
# Statistics (>=1.9)
self.statsSampleSize = 2500000
self.stats = {} # stats per layer
self.layersSelected=[]
self.layerBands=dict()
self.iface=iface
self.canvas=self.iface.mapCanvas
self.legend=self.iface.legendInterface()
self.logger = logging.getLogger('.'.join((__name__,
self.__class__.__name__)))
QWidget.__init__(self)
self.setupUi(self)
self.tabWidget.setEnabled(False)
self.cbxClick.setChecked( QSettings().value('plugins/valuetool/mouseClick', False, type=bool ) )
#self.setupUi_plot()
#don't setup plot until Plot tab is clicked - workaround for bug #7450
#qgis will still crash in some cases, but at least the tool can be used in Table mode
self.qwtPlot = None
self.mplPlot = None
self.mplLine = None
QObject.connect(self.plotSelector, SIGNAL( "currentIndexChanged ( int )" ), self.changePlot )
QObject.connect(self.tabWidget, SIGNAL( "currentChanged ( int )" ), self.tabWidgetChanged )
QObject.connect(self.cbxLayers, SIGNAL( "currentIndexChanged ( int )" ), self.updateLayers )
QObject.connect(self.cbxBands, SIGNAL( "currentIndexChanged ( int )" ), self.updateLayers )
QObject.connect(self.tableWidget2, SIGNAL("cellChanged ( int , int )"), self.layerSelected)
def setupUi_plot(self):
# plot
self.plotSelector.setVisible( False )
self.cbxStats.setVisible( False )
# stats by default because estimated are fast
self.cbxStats.setChecked( True )
self.plotSelector.addItem( 'Qwt' )
self.plotSelector.addItem( 'mpl' )
# Page 2 - qwt
if self.hasqwt:
self.qwtPlot = QwtPlot(self.stackedWidget)
self.qwtPlot.setAutoFillBackground(False)
self.qwtPlot.setObjectName("qwtPlot")
self.curve = QwtPlotCurve()
self.curve.setSymbol(
QwtSymbol(QwtSymbol.Ellipse,
QBrush(Qt.white),
QPen(Qt.red, 2),
QSize(9, 9)))
self.curve.attach(self.qwtPlot)
else:
self.qwtPlot = QtGui.QLabel("Need Qwt >= 5.0 or matplotlib >= 1.0 !")
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.qwtPlot.sizePolicy().hasHeightForWidth())
self.qwtPlot.setSizePolicy(sizePolicy)
self.qwtPlot.updateGeometry()
self.stackedWidget.addWidget(self.qwtPlot)
#Page 3 - matplotlib
self.mplLine = None #make sure to invalidate when layers change
if self.hasmpl:
# mpl stuff
# should make figure light gray
self.mplBackground = None #http://www.scipy.org/Cookbook/Matplotlib/Animations
self.mplFig = plt.Figure(facecolor='w', edgecolor='w')
self.mplFig.subplots_adjust(left=0.1, right=0.975, bottom=0.13, top=0.95)
self.mplPlt = self.mplFig.add_subplot(111)
self.mplPlt.tick_params(axis='both', which='major', labelsize=12)
self.mplPlt.tick_params(axis='both', which='minor', labelsize=10)
# qt stuff
self.pltCanvas = FigureCanvasQTAgg(self.mplFig)
self.pltCanvas.setParent(self.stackedWidget)
self.pltCanvas.setAutoFillBackground(False)
self.pltCanvas.setObjectName("mplPlot")
self.mplPlot = self.pltCanvas
else:
self.mplPlot = QtGui.QLabel("Need Qwt >= 5.0 or matplotlib >= 1.0 !")
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.mplPlot.sizePolicy().hasHeightForWidth())
#.........这里部分代码省略.........
示例2: ValueWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setAutoFillBackground [as 别名]
class ValueWidget(QWidget, Ui_Widget):
def __init__(self, iface):
self.hasqwt=hasqwt
self.hasmpl=hasmpl
self.layerMap=dict()
self.statsChecked=False
self.ymin=0
self.ymax=250
self.iface=iface
self.canvas=self.iface.mapCanvas()
self.legend=self.iface.legendInterface()
self.logger = logging.getLogger('.'.join((__name__,
self.__class__.__name__)))
QWidget.__init__(self)
self.setupUi(self)
self.setupUi_extra()
QObject.connect(self.cbxActive,SIGNAL("stateChanged(int)"),self.changeActive)
QObject.connect(self.cbxGraph,SIGNAL("stateChanged(int)"),self.changePage)
QObject.connect(self.canvas, SIGNAL( "keyPressed( QKeyEvent * )" ), self.pauseDisplay )
QObject.connect(self.plotSelector, SIGNAL( "currentIndexChanged ( int )" ), self.changePlot )
def setupUi_extra(self):
# checkboxes
#self.changeActive(Qt.Checked)
#set inactive by default - should save last state in user config
self.cbxActive.setCheckState(Qt.Unchecked)
# plot
self.plotSelector.setVisible( False )
self.cbxStats.setVisible( False )
self.graphControls.setVisible( False )
if self.hasqwt:
self.plotSelector.addItem( 'Qwt' )
if self.hasmpl:
self.plotSelector.addItem( 'mpl' )
self.plotSelector.setCurrentIndex( 0 );
if (not self.hasqwt or not self.hasmpl):
#self.plotSelector.setVisible(False)
self.plotSelector.setEnabled(False)
# Page 2 - qwt
if self.hasqwt:
self.qwtPlot = QwtPlot(self.stackedWidget)
self.qwtPlot.setAutoFillBackground(False)
self.qwtPlot.setObjectName("qwtPlot")
self.curve = QwtPlotCurve()
self.curve.setSymbol(
QwtSymbol(QwtSymbol.Ellipse,
QBrush(Qt.white),
QPen(Qt.red, 2),
QSize(9, 9)))
self.curve.attach(self.qwtPlot)
self.qwtPlot.setVisible(False)
else:
self.qwtPlot = QtGui.QLabel("Need Qwt >= 5.0 or matplotlib >= 1.0 !")
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.qwtPlot.sizePolicy().hasHeightForWidth())
self.qwtPlot.setSizePolicy(sizePolicy)
self.qwtPlot.setObjectName("qwtPlot")
self.qwtPlot.updateGeometry()
self.stackedWidget.addWidget(self.qwtPlot)
#Page 3 - matplotlib
self.mplLine = None #make sure to invalidate when layers change
if self.hasmpl:
# mpl stuff
# should make figure light gray
self.mplBackground = None #http://www.scipy.org/Cookbook/Matplotlib/Animations
self.mplFig = plt.Figure(facecolor='w', edgecolor='w')
self.mplFig.subplots_adjust(left=0.1, right=0.975, bottom=0.13, top=0.95)
self.mplPlt = self.mplFig.add_subplot(111)
self.mplPlt.tick_params(axis='both', which='major', labelsize=12)
self.mplPlt.tick_params(axis='both', which='minor', labelsize=10)
# qt stuff
self.pltCanvas = FigureCanvasQTAgg(self.mplFig)
self.pltCanvas.setParent(self.stackedWidget)
self.pltCanvas.setAutoFillBackground(False)
self.pltCanvas.setObjectName("mplPlot")
self.mplPlot = self.pltCanvas
self.mplPlot.setVisible(False)
else:
self.mplPlot = QtGui.QLabel("Need Qwt >= 5.0 or matplotlib >= 1.0 !")
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.mplPlot.sizePolicy().hasHeightForWidth())
self.mplPlot.setSizePolicy(sizePolicy)
self.qwtPlot.setObjectName("qwtPlot")
self.mplPlot.updateGeometry()
self.stackedWidget.addWidget(self.mplPlot)
#.........这里部分代码省略.........
示例3: ProfileDockWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setAutoFillBackground [as 别名]
#.........这里部分代码省略.........
self.__displayMnt = False
self.__mntButton.setText(QCoreApplication.translate("VDLTools", "Display MNT"))
else:
self.__displayMnt = True
self.__mntButton.setText(QCoreApplication.translate("VDLTools", "Remove MNT"))
def __zeros(self):
"""
To toggle if we want to display zero elevations or not
"""
if self.__displayZeros:
self.__displayZeros = False
self.__zerosButton.setText(QCoreApplication.translate("VDLTools", "Display Zeros"))
else:
self.__displayZeros = True
self.__zerosButton.setText(QCoreApplication.translate("VDLTools", "Remove Zeros"))
def __changePlotWidget(self):
"""
When plot widget is change (qwt <-> matplotlib)
"""
self.__activateMouseTracking(False)
while self.__frameLayout.count():
child = self.__frameLayout.takeAt(0)
child.widget().deleteLater()
self.__plotWdg = None
if self.__lib == 'Qwt5':
self.__plotWdg = QwtPlot(self.__plotFrame)
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(10)
sizePolicy.setVerticalStretch(0)
self.__plotWdg.setSizePolicy(sizePolicy)
self.__plotWdg.setAutoFillBackground(False)
# Decoration
self.__plotWdg.setCanvasBackground(Qt.white)
self.__plotWdg.plotLayout().setAlignCanvasToScales(False)
self.__plotWdg.plotLayout().setSpacing(100)
self.__plotWdg.plotLayout().setCanvasMargin(10, QwtPlot.xBottom)
self.__plotWdg.plotLayout().setCanvasMargin(10, QwtPlot.yLeft)
title = QwtText(QCoreApplication.translate("VDLTools", "Distance [m]"))
title.setFont(QFont("Helvetica", 10))
self.__plotWdg.setAxisTitle(QwtPlot.xBottom, title)
title.setText(QCoreApplication.translate("VDLTools", "Elevation [m]"))
title.setFont(QFont("Helvetica", 10))
self.__plotWdg.setAxisTitle(QwtPlot.yLeft, title)
self.__zoomer = QwtPlotZoomer(QwtPlot.xBottom, QwtPlot.yLeft, QwtPicker.DragSelection, QwtPicker.AlwaysOff,
self.__plotWdg.canvas())
self.__zoomer.setRubberBandPen(QPen(Qt.blue))
grid = QwtPlotGrid()
grid.setPen(QPen(QColor('grey'), 0, Qt.DotLine))
grid.attach(self.__plotWdg)
self.__frameLayout.addWidget(self.__plotWdg)
elif self.__lib == 'Matplotlib':
fig = Figure((1.0, 1.0), linewidth=0.0, subplotpars=SubplotParams(left=0, bottom=0, right=1, top=1,
wspace=0, hspace=0))
font = {'family': 'arial', 'weight': 'normal', 'size': 12}
rc('font', **font)
rect = fig.patch
rect.set_facecolor((0.9, 0.9, 0.9))
self.__axes = fig.add_axes((0.07, 0.16, 0.92, 0.82))
self.__axes.set_xbound(0, 1000)