当前位置: 首页>>代码示例>>Python>>正文


Python FigureCanvasQTAgg.print_figure方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg.print_figure方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.print_figure方法的具体用法?Python FigureCanvasQTAgg.print_figure怎么用?Python FigureCanvasQTAgg.print_figure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg的用法示例。


在下文中一共展示了FigureCanvasQTAgg.print_figure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plotData

# 需要导入模块: from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg import print_figure [as 别名]

#.........这里部分代码省略.........
    axes.set_xlabel(horiLabel, fontsize=12)
    axes.set_ylabel(vertiLabel, verticalalignment='top', fontsize=12,
                    horizontalalignment='center', labelpad=20)
    axes.set_title(titelLabel, fontsize=13, multialignment='center', y=1.05)
    # Achsen anpassen
    axes.set_ylim([data_ylow, data_yhi])
    axes.set_xlim([data_xlow, data_xhi])
    axes.set_aspect('equal')
    stepx = 10
    stepy = 10
    if data_xhi >= 300:
        stepx = 20
    if data_xhi >= 500:
        stepy = 20      # sieht besser aus
    if data_xhi >= 700:
        stepx = 25
    if data_ylen >= 400:
        stepy = 20
    axes.set_yticks([i for i in range(int(data_ylow), int(data_yhi))
                     if i % stepy == 0])
    axes.set_xticks([i for i in range(int(data_xlow), int(data_xhi))
                     if i % stepx == 0])
    axes.grid()

    # Legende erzeugen
    fontP = FontProperties()
    fontP.set_size('medium')
    # Zusätzliche Beschreibung für fixe Stützen Beschriftung
    ncol = 3
    if np.sum(findFixStueX) > 0:
        ncol = 4
        axes.plot([data_xlow], [data_ylow], linewidth=0,
                  label=("Fixe Stützen: ° = fixe Position, "
                         "°* = fixe Position und Höhe"))
    axes.legend(loc='lower center', prop=fontP, bbox_to_anchor=(0.5, 0),
                ncol=ncol)

    # Annotiations (Beschriftungen im Graph) und Text für Report vorbereiten
    # ----------------------------------------------------------------------
    # Stützenbeschriftungen
    stueLabel = ["Anfangsstütze",  "Endstütze"]
    # Feldbeschriftungen
    feldLabel = []
    # Zwischenstützen hinzufügen
    i = 0
    for i in range(1, len(idxStue)-1):
        marker = ''
        if findFixStueX[i] > 0:
            marker = '°'
            if findFixStueZ[i] > 0:
                marker = '°*'
        stueLabel.insert(i, "{}. Stütze{}".format(i+1, marker))
        feldLabel.insert(i-1, "{}. Feld".format(i))
    # Letztes Feld hinzufügen
    feldLabel.insert(i, "{}. Feld".format(i+1))

    # Formatierung der Angaben für Stützenhöhen
    stueLabelH = []
    for i in range(len(hoeheStue)):
        if hoeheStue[i] == 0:        # Keine Höhenangabe falls Stütze == Anker
            stueLabelH.append("")
        else:
            # Formatierung je nach Zahlentyp mit oder ohne Nachkommastellen
            if hoeheStue[i]%1 == 0.0:
                stueLabelH.append("{:.0f} m".format(hoeheStue[i]))
            else:
                stueLabelH.append("{:.1f} m".format(hoeheStue[i]))

    for i in range(len(idxStue)):
        axes.annotate(stueLabel[i], xy=(idxStue[i], zStue[i]),
                     xycoords='data', xytext=(-25, 20),
                     textcoords='offset points', size=12,
                     path_effects=[PathEffects.withStroke(linewidth=3, foreground="w")])
        axes.annotate(stueLabelH[i], xy=(idxStue[i], zStue[i]-zStue[i]/2),
                     xycoords='data', xytext=(5, -5),
                     textcoords='offset points', size=12,
                     path_effects=[PathEffects.withStroke(linewidth=3, foreground="w")])

    # Abschnittsbeschriftungen
    for i in range(len(idxStue)-1):
        coordX = idxStue[i] + 0.5*(idxStue[i+1] - idxStue[i])
        coordY = zStue[i] + 0.5*(zStue[i+1] - zStue[i])
        axes.annotate(feldLabel[i], xy=(coordX, coordY),
                     xycoords='data', xytext=(-30, 25), style='italic',
                     textcoords='offset points', size=12,
                     path_effects=[PathEffects.withStroke(linewidth=3, foreground="w")])
    # Bezeichnung der fixen Stützen
    
    # TODO: Funktioniert unter Windows nicht
    # fig.tight_layout()

    # Plot als PNG exportieren
    # outPlotPNG = os.path.join(outputLoc, '{}_Plot.png'.format(outputName))
    outPlotPDF = os.path.join(locPlot)
    # canvas.print_png(outPlotPNG, dpi=dpi)
    canvas.print_figure(outPlotPDF)
    del canvas
    del fig

    return outPlotPDF, [stueLabel, feldLabel]
开发者ID:piMoll,项目名称:SEILAPLAN,代码行数:104,代码来源:outputReport.py

示例2: AppForm

# 需要导入模块: from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg import print_figure [as 别名]

#.........这里部分代码省略.........
        self.info_popup(dct, "Account identifiers")
    
    def info_cat_acc(self, lst):
        dct = OrderedDict()
        for item_idx in xrange(lst.count()):
            item = lst.item(item_idx)
            uid = item.data(Qt.UserRole).values()[0]
            name = item.text()
            dct[name] = uid
        return dct
        
    def info_options(self):
        options = {"Legend":"legend", "Inverted": "invert"}
        self.info_popup(options, "Options keywords") 
        
    def info_popup(self, dct, title):
        msg = "\n".join(["%s --> %s" % (name, opt) for name, opt in dct.items()])
        QMessageBox.about(self, title, msg)
        
    def save_plot(self, path=None):
        if path is None:
            file_choices = "PNG (*.png)"
            
            path = QFileDialog.getSaveFileName(self, 
                                               'Save file', '', 
                                               file_choices)
            if not (path and path[0]):
              return

            path = path[0]

        if not path.endswith(".png"): path += ".png"
        
        self.canvas.print_figure(path, dpi=self.dpi)
        return path
            
    def open_grisbi(self, initial=False):
        file_choices = "Grisbi Account (*.gsb)"
        path = QFileDialog.getOpenFileName(self, 
                                           'Open file', '', 
                                           file_choices)
        if not path:
          return
        path = path[0]
        if not os.path.exists(path):
          return
        
        self.src = GrisbiDataProvider(path)
        if not initial:
          self.populateAccCat()
          self.set_startstop_dates()
        self.set_current_file(path)
          
        return path
    
    def current_config(self):
        conf_str = str(self.create_config())
        
        QMessageBox.information(self, "Current configuration", str(conf_str))
        
    def create_config(self):
        selected = []
        for item_idx in xrange(self.listSelected.count()):
            item = self.listSelected.item(item_idx)
            uid = item.data(Qt.UserRole)
            selected.append(uid)
开发者ID:wazari972,项目名称:Grisbi-Data-Analyzer,代码行数:70,代码来源:Gui.py


注:本文中的matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg.print_figure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。