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


Python rcParams.get方法代码示例

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


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

示例1: button_press_event

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def button_press_event(self, widget, event):
        if _debug: print('FigureCanvasGTK.%s' % fn_name())
        x = event.x
        # flipy so y=0 is bottom of canvas
        y = self.allocation.height - event.y
        dblclick = (event.type == gdk._2BUTTON_PRESS)
        if not dblclick:
            # GTK is the only backend that generates a DOWN-UP-DOWN-DBLCLICK-UP  event
            # sequence for a double click.  All other backends have a DOWN-UP-DBLCLICK-UP
            # sequence.  In order to provide consistency to matplotlib users, we will
            # eat the extra DOWN event in the case that we detect it is part of a double
            # click.
            # first, get the double click time in milliseconds.
            current_time  = event.get_time()
            last_time     = self.last_downclick.get(event.button,0)
            dblclick_time = gtk.settings_get_for_screen(gdk.screen_get_default()).get_property('gtk-double-click-time')
            delta_time    = current_time-last_time
            if delta_time < dblclick_time:
                del self.last_downclick[event.button] # we do not want to eat more than one event.
                return False                          # eat.
            self.last_downclick[event.button] = current_time
        FigureCanvasBase.button_press_event(self, x, y, event.button, dblclick=dblclick, guiEvent=event)
        return False  # finish event propagation? 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:backend_gtk.py

示例2: save_figure

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def save_figure(self, *args):
        chooser = self.get_filechooser()
        fname, format = chooser.get_filename_from_user()
        chooser.destroy()
        if fname:
            startpath = os.path.expanduser(rcParams.get('savefig.directory', ''))
            if startpath == '':
                # explicitly missing key or empty str signals to use cwd
                rcParams['savefig.directory'] = startpath
            else:
                # save dir for next time
                rcParams['savefig.directory'] = os.path.dirname(unicode(fname))
            try:
                self.canvas.print_figure(fname, format=format)
            except Exception as e:
                error_msg_gtk(str(e), parent=self) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:backend_gtk.py

示例3: get_fontspec

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def get_fontspec():
    """Build fontspec preamble from rc."""
    latex_fontspec = []
    texcommand = get_texcommand()

    if texcommand != "pdflatex":
        latex_fontspec.append(r"\usepackage{fontspec}")

    if texcommand != "pdflatex" and rcParams.get("pgf.rcfonts", True):
        # try to find fonts from rc parameters
        families = ["serif", "sans-serif", "monospace"]
        fontspecs = [r"\setmainfont{%s}", r"\setsansfont{%s}",
                     r"\setmonofont{%s}"]
        for family, fontspec in zip(families, fontspecs):
            matches = [f for f in rcParams["font." + family]
                       if f in system_fonts]
            if matches:
                latex_fontspec.append(fontspec % matches[0])
            else:
                pass  # no fonts found, fallback to LaTeX defaule

    return "\n".join(latex_fontspec) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:backend_pgf.py

示例4: get_latex_manager

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def get_latex_manager():
        texcommand = get_texcommand()
        latex_header = LatexManager._build_latex_header()
        prev = LatexManagerFactory.previous_instance

        # check if the previous instance of LatexManager can be reused
        if prev and prev.latex_header == latex_header and prev.texcommand == texcommand:
            if rcParams.get("pgf.debug", False):
                print("reusing LatexManager")
            return prev
        else:
            if rcParams.get("pgf.debug", False):
                print("creating LatexManager")
            new_inst = LatexManager()
            LatexManagerFactory.previous_instance = new_inst
            return new_inst 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:backend_pgf.py

示例5: __init__

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def __init__(self, figure, fh, dummy=False):
        """
        Creates a new PGF renderer that translates any drawing instruction
        into text commands to be interpreted in a latex pgfpicture environment.

        Attributes:
        * figure: Matplotlib figure to initialize height, width and dpi from.
        * fh: File handle for the output of the drawing commands.
        """
        RendererBase.__init__(self)
        self.dpi = figure.dpi
        self.fh = fh
        self.figure = figure
        self.image_counter = 0

        # get LatexManager instance
        self.latexManager = LatexManagerFactory.get_latex_manager()

        # dummy==True deactivate all methods
        if dummy:
            nop = lambda *args, **kwargs: None
            for m in RendererPgf.__dict__.keys():
                if m.startswith("draw_"):
                    self.__dict__[m] = nop 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:backend_pgf.py

示例6: print_pgf

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def print_pgf(self, fname_or_fh, *args, **kwargs):
        """
        Output pgf commands for drawing the figure so it can be included and
        rendered in latex documents.
        """
        if kwargs.get("dryrun", False):
            self._print_pgf_to_fh(None, *args, **kwargs)
            return

        # figure out where the pgf is to be written to
        if is_string_like(fname_or_fh):
            with codecs.open(fname_or_fh, "w", encoding="utf-8") as fh:
                self._print_pgf_to_fh(fh, *args, **kwargs)
        elif is_writable_file_like(fname_or_fh):
            raise ValueError("saving pgf to a stream is not supported, " +
                             "consider using the pdf option of the pgf-backend")
        else:
            raise ValueError("filename must be a path") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,代码来源:backend_pgf.py

示例7: print_pdf

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def print_pdf(self, fname_or_fh, *args, **kwargs):
        """
        Use LaTeX to compile a Pgf generated figure to PDF.
        """
        if kwargs.get("dryrun", False):
            self._print_pgf_to_fh(None, *args, **kwargs)
            return

        # figure out where the pdf is to be written to
        if is_string_like(fname_or_fh):
            with open(fname_or_fh, "wb") as fh:
                self._print_pdf_to_fh(fh, *args, **kwargs)
        elif is_writable_file_like(fname_or_fh):
            self._print_pdf_to_fh(fname_or_fh, *args, **kwargs)
        else:
            raise ValueError("filename must be a path or a file-like object") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:backend_pgf.py

示例8: save_figure

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def save_figure(self, *args):
        chooser = self.get_filechooser()
        fname, format = chooser.get_filename_from_user()
        chooser.destroy()
        if fname:
            startpath = os.path.expanduser(rcParams.get('savefig.directory', ''))
            if startpath == '':
                # explicitly missing key or empty str signals to use cwd
                rcParams['savefig.directory'] = startpath
            else:
                # save dir for next time
                rcParams['savefig.directory'] = os.path.dirname(six.text_type(fname))
            try:
                self.canvas.print_figure(fname, format=format)
            except Exception as e:
                error_msg_gtk(str(e), parent=self) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:18,代码来源:backend_gtk.py

示例9: get_fontspec

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def get_fontspec():
    """Build fontspec preamble from rc."""
    latex_fontspec = []
    texcommand = get_texcommand()

    if texcommand != "pdflatex":
        latex_fontspec.append("\\usepackage{fontspec}")

    if texcommand != "pdflatex" and rcParams.get("pgf.rcfonts", True):
        # try to find fonts from rc parameters
        families = ["serif", "sans-serif", "monospace"]
        fontspecs = [r"\setmainfont{%s}", r"\setsansfont{%s}",
                     r"\setmonofont{%s}"]
        for family, fontspec in zip(families, fontspecs):
            matches = [f for f in rcParams["font." + family]
                       if f in system_fonts]
            if matches:
                latex_fontspec.append(fontspec % matches[0])
            else:
                pass  # no fonts found, fallback to LaTeX defaule

    return "\n".join(latex_fontspec) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:24,代码来源:backend_pgf.py

示例10: print_pgf

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import get [as 别名]
def print_pgf(self, fname_or_fh, *args, **kwargs):
        """
        Output pgf commands for drawing the figure so it can be included and
        rendered in latex documents.
        """
        if kwargs.get("dryrun", False):
            self._print_pgf_to_fh(None, *args, **kwargs)
            return

        # figure out where the pgf is to be written to
        if is_string_like(fname_or_fh):
            with codecs.open(fname_or_fh, "w", encoding="utf-8") as fh:
                self._print_pgf_to_fh(fh, *args, **kwargs)
        elif is_writable_file_like(fname_or_fh):
            if not os.path.exists(fname_or_fh.name):
                warnings.warn("streamed pgf-code does not support raster "
                              "graphics, consider using the pgf-to-pdf option",
                              UserWarning)
            self._print_pgf_to_fh(fname_or_fh, *args, **kwargs)
        else:
            raise ValueError("filename must be a path") 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:23,代码来源:backend_pgf.py


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