本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.clear方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.clear方法的具体用法?Python FigureCanvasQTAgg.clear怎么用?Python FigureCanvasQTAgg.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProfileDockWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import clear [as 别名]
#.........这里部分代码省略.........
else:
self.__iface.messageBar().pushMessage(
QCoreApplication.translate("VDLTools", "Invalid index ") + str(idx),
level=QgsMessageBar.CRITICAL, duration=0)
def __outPDF(self):
"""
To save the profile as pdf file
"""
fileName = QFileDialog.getSaveFileName(
self.__iface.mainWindow(), QCoreApplication.translate("VDLTools", "Save As"),
QCoreApplication.translate("VDLTools", "Profile.pdf"),"Portable Document Format (*.pdf)")
if fileName is not None:
if self.__lib == 'Qwt5':
printer = QPrinter()
printer.setCreator(QCoreApplication.translate("VDLTools", "QGIS Profile Plugin"))
printer.setOutputFileName(fileName)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOrientation(QPrinter.Landscape)
self.__plotWdg.print_(printer)
elif self.__lib == 'Matplotlib':
self.__plotWdg.figure.savefig(str(fileName))
def __outPNG(self):
"""
To save the profile as png file
"""
fileName = QFileDialog.getSaveFileName(
self.__iface.mainWindow(), QCoreApplication.translate("VDLTools", "Save As"),
QCoreApplication.translate("VDLTools", "Profile.png"),"Portable Network Graphics (*.png)")
if fileName is not None:
QPixmap.grabWidget(self.__printWdg).save(fileName, "PNG")
def clearData(self):
"""
To clear the displayed data
"""
if self.__profiles is None:
return
if self.__lib == 'Qwt5':
self.__plotWdg.clear()
self.__profiles = None
temp1 = self.__plotWdg.itemList()
for j in range(len(temp1)):
if temp1[j].rtti() == QwtPlotItem.Rtti_PlotCurve:
temp1[j].detach()
elif self.__lib == 'Matplotlib':
self.__plotWdg.figure.get_axes()[0].cla()
self.__manageMatplotlibAxe(self.__plotWdg.figure.get_axes()[0])
self.__maxSpin.setEnabled(False)
self.__minSpin.setEnabled(False)
self.__maxSpin.setValue(0)
self.__minSpin.setValue(0)
# clear legend
while self.__legendLayout.count():
child = self.__legendLayout.takeAt(0)
child.widget().deleteLater()
def __manageMatplotlibAxe(self, axe):
"""
To manage the axes for matplotlib library
:param axe: the axes element
"""
axe.grid()
axe.tick_params(axis="both", which="major", direction="out", length=10, width=1, bottom=True, top=False,