• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pylab.switch_backend函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pylab.switch_backend函数的典型用法代码示例。如果您正苦于以下问题:Python switch_backend函数的具体用法?Python switch_backend怎么用?Python switch_backend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_plot_functions

def test_plot_functions():
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    img = nibabel.Nifti1Image(data, mni_affine)
    ortho_slicer = plot_anat(img, dim=True)
    # Test saving with empty plot
    z_slicer = plot_anat(anat_img=False, display_mode='z')
    ortho_slicer.savefig(tempfile.TemporaryFile())
    z_slicer = plot_anat(display_mode='z')
    ortho_slicer.savefig(tempfile.TemporaryFile())
    z_slicer.add_edges(img, color='c')

    for func in [plot_anat, plot_img, plot_stat_map,
                 plot_epi, plot_glass_brain]:
        ortho_slicer = func(img, cut_coords=(80, -120, -60))
        # Saving forces a draw, and thus smoke-tests the axes locators
        ortho_slicer.savefig(tempfile.TemporaryFile())
        ortho_slicer.add_edges(img, color='c')

        # Smoke test coordinate finder, with and without mask
        masked_img = nibabel.Nifti1Image(np.ma.masked_equal(data, 0),
                                         mni_affine)
        func(masked_img, display_mode='x')
        func(img, display_mode='y')

        out = func(img, output_file=tempfile.TemporaryFile(suffix='.png'))
        assert_true(out is None)
    pl.close('all')
开发者ID:ofercoq,项目名称:nilearn,代码行数:32,代码来源:test_img_plotting.py


示例2: reason_pylab

def reason_pylab():
    from .utils import deliver_image
    def _canvas_deliver(canvas):
        tf = tempfile.TemporaryFile()
        canvas.print_png(tf)
        tf.seek(0)
        img_data = base64.b64encode(tf.read())
        tf.close()
        deliver_image(img_data)
    def reason_draw_if_interactive():
        if matplotlib.is_interactive():
            figManager =  Gcf.get_active()
            if figManager is not None:
                _canvas_deliver(figManager.canvas)
    def reason_show(mainloop = True):
        # We ignore mainloop here
        for manager in Gcf.get_all_fig_managers():
            _canvas_deliver(manager.canvas)
    # Matplotlib has very nice backend overriding.
    # We should really use that.  This is just a hack.
    import matplotlib
    matplotlib.use("agg") # Hotfix for when we import pylab below
    new_agg = imp.new_module("reason_agg")
    import matplotlib.backends.backend_agg as bagg
    new_agg.__dict__.update(bagg.__dict__)
    new_agg.__dict__.update(
        {'show': reason_show,
         'draw_if_interactive': reason_draw_if_interactive})
    sys.modules["reason_agg"] = new_agg
    bagg.draw_if_interactive = reason_draw_if_interactive
    from matplotlib._pylab_helpers import Gcf
    matplotlib.rcParams["backend"] = "module://reason_agg"
    import pylab
    pylab.switch_backend("module://reason_agg")
开发者ID:danielgrassinger,项目名称:yt_new_frontend,代码行数:34,代码来源:extdirect_repl.py


示例3: test_demo_plot_map

def test_demo_plot_map():
    # This is only a smoke test
    mp.use("svg", warn=False)
    import pylab as pl

    pl.switch_backend("svg")
    demo_plot_map()
开发者ID:neurospin,项目名称:nipy,代码行数:7,代码来源:test_activation_maps.py


示例4: test_plot_anat

def test_plot_anat():
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    img = nibabel.Nifti1Image(data, mni_affine)
    ortho_slicer = plot_anat(img, dim=True)
    ortho_slicer = plot_anat(img, cut_coords=(80, -120, -60))
    # Saving forces a draw, and thus smoke-tests the axes locators
    pl.savefig(tempfile.TemporaryFile())
    ortho_slicer.edge_map(img, color='c')

    # Test saving with empty plot
    z_slicer = plot_anat(anat_img=False, slicer='z')
    pl.savefig(tempfile.TemporaryFile())
    z_slicer = plot_anat(slicer='z')
    pl.savefig(tempfile.TemporaryFile())
    z_slicer.edge_map(img, color='c')
    # Smoke test coordinate finder, with and without mask
    masked_img = nibabel.Nifti1Image(np.ma.masked_equal(data, 0),
                                     mni_affine)
    plot_img(masked_img, slicer='x')
    plot_img(img, slicer='y')
开发者ID:VirgileFritsch,项目名称:nilearn,代码行数:25,代码来源:test_img_plotting.py


示例5: test_replace_inside

def test_replace_inside():
    # This is only a smoke test
    mp.use("svg", warn=False)
    import pylab as pl

    pl.switch_backend("svg")
    replace_inside(pl.cm.jet, pl.cm.hsv, 0.2, 0.8)
开发者ID:schwarty,项目名称:nipy,代码行数:7,代码来源:test_cm.py


示例6: test_replace_inside

def test_replace_inside():
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    replace_inside(pl.cm.jet, pl.cm.hsv, .2, .8)
    # We also test with gnuplot, which is defined using function
    replace_inside(pl.cm.gnuplot, pl.cm.gnuplot2, .2, .8)
开发者ID:FNNDSC,项目名称:nipy,代码行数:8,代码来源:test_cm.py


示例7: test_demo_plot_map

def test_demo_plot_map():
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    demo_plot_map()
    # Test the black background code path
    demo_plot_map(black_bg=True)
开发者ID:VirgileFritsch,项目名称:nipy,代码行数:8,代码来源:test_activation_maps.py


示例8: test_plot_map_with_auto_cut_coords

def test_plot_map_with_auto_cut_coords():
    import pylab as pl
    pl.switch_backend('svg')
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1

    for slicer in 'xyz':
        plot_map(data, np.eye(4), cut_coords=None, slicer=slicer,
                 black_bg=True)
开发者ID:Naereen,项目名称:nipy,代码行数:9,代码来源:test_activation_maps.py


示例9: test_plot_anat

def test_plot_anat():
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    ortho_slicer = plot_anat()
    data = np.zeros((100, 100, 100))
    data[3:-3, 3:-3, 3:-3] = 1
    ortho_slicer.edge_map(data, mni_sform, color='c')
开发者ID:Hiccup,项目名称:nipy,代码行数:9,代码来源:test_activation_maps.py


示例10: test_demo_ortho_slicer

def test_demo_ortho_slicer():
    # This is only a smoke test
    # conditioned on presence of MNI templated
    if not find_mni_template():
        raise nose.SkipTest("MNI Template is absent for the smoke test")
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    demo_ortho_slicer()
开发者ID:Hiccup,项目名称:nipy,代码行数:9,代码来源:test_ortho_slicer.py


示例11: test_plot_img_with_auto_cut_coords

def test_plot_img_with_auto_cut_coords():
    import pylab as pl
    pl.switch_backend('svg')
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    img = nibabel.Nifti1Image(data, np.eye(4))

    for slicer in 'xyz':
        plot_img(img, cut_coords=None, slicer=slicer, black_bg=True)
开发者ID:VirgileFritsch,项目名称:nilearn,代码行数:9,代码来源:test_img_plotting.py


示例12: test_demo_ortho_slicer

def test_demo_ortho_slicer():
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    pl.clf()
    oslicer = OrthoSlicer(cut_coords=(0, 0, 0))
    img = load_mni152_template()
    oslicer.add_overlay(img, cmap=pl.cm.gray)
    oslicer.close()
开发者ID:abenicho,项目名称:nilearn,代码行数:10,代码来源:test_slicers.py


示例13: test_demo_plot_roi

def test_demo_plot_roi():
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    demo_plot_roi()
    # Test the black background code path
    demo_plot_roi(black_bg=True)

    out = demo_plot_roi(output_file=tempfile.TemporaryFile(suffix='.png'))
    assert_true(out is None)
开发者ID:ofercoq,项目名称:nilearn,代码行数:11,代码来源:test_img_plotting.py


示例14: test_demo_ortho_projector

def test_demo_ortho_projector():
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    pl.clf()
    img = load_mni152_template()
    oprojector = OrthoProjector.init_with_figure(img=img)
    oprojector.add_overlay(img, cmap=pl.cm.gray)
    oprojector.savefig(tempfile.TemporaryFile())
    oprojector.close()
开发者ID:ofercoq,项目名称:nilearn,代码行数:11,代码来源:test_displays.py


示例15: test_stacked_slicer

def test_stacked_slicer():
    # Test stacked slicers, like the XSlicer
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    pl.clf()
    img = load_mni152_template()
    slicer = XSlicer.init_with_figure(img=img, cut_coords=3)
    slicer.add_overlay(img, cmap=pl.cm.gray)
    # Forcing a layout here, to test the locator code
    slicer.savefig(tempfile.TemporaryFile())
    slicer.close()
开发者ID:abenicho,项目名称:nilearn,代码行数:12,代码来源:test_slicers.py


示例16: test_plot_img_empty

def test_plot_img_empty():
    # Test that things don't crash when we give a map with nothing above
    # threshold
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    data = np.zeros((20, 20, 20))
    img = nibabel.Nifti1Image(data, mni_affine)
    plot_anat(img)
    plot_img(img, slicer='y', threshold=1)
    pl.close('all')
开发者ID:VirgileFritsch,项目名称:nilearn,代码行数:12,代码来源:test_img_plotting.py


示例17: test_demo_ortho_slicer

def test_demo_ortho_slicer():
    # This is only a smoke test
    # conditioned on presence of MNI templated
    if not find_mni_template():
        raise nose.SkipTest("MNI Template is absent for the smoke test")
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    pl.clf()
    oslicer = OrthoSlicer(cut_coords=(0, 0, 0))
    img, _ = _AnatCache.get_anat()
    oslicer.add_overlay(img, cmap=pl.cm.gray)
开发者ID:GaelVaroquaux,项目名称:tmp_viz,代码行数:12,代码来源:test_slicers.py


示例18: test_plot_anat

def test_plot_anat():
    # This is only a smoke test
    mp.use("svg", warn=False)
    import pylab as pl

    pl.switch_backend("svg")
    data = np.zeros((20, 20, 20))
    data[3:-3, 3:-3, 3:-3] = 1
    ortho_slicer = plot_anat(data, mni_sform, dim=True)
    ortho_slicer = plot_anat(data, mni_sform, cut_coords=(80, -120, -60))
    # Saving forces a draw, and thus smoke-tests the axes locators
    pl.savefig(tempfile.TemporaryFile())
    ortho_slicer.edge_map(data, mni_sform, color="c")

    z_slicer = plot_anat(slicer="z")
    pl.savefig(tempfile.TemporaryFile())
    z_slicer.edge_map(data, mni_sform, color="c")
    # Smoke test coordinate finder, with and without mask
    plot_map(np.ma.masked_equal(data, 0), mni_sform, slicer="x")
    plot_map(data, mni_sform, slicer="y")
开发者ID:neurospin,项目名称:nipy,代码行数:20,代码来源:test_activation_maps.py


示例19: switch_backend

	stat.py
	Used to create plots of execution times.
	
	Stronly inspired by http://stackoverflow.com/a/16598291/4620080

	Author: Martin Storgaard and Konstantinos Mampentzidis
"""
from pylab import plot, show, savefig, xlim, figure, \
                hold, ylim, legend, boxplot, setp, axes, \
                title, ylabel, xlabel, subplots_adjust, suptitle, switch_backend

from utils import get_test_cases, get_test_case
from sys import argv
import numpy as np
switch_backend('TKAgg')
# Built-in colors: Blue, Green, Red,
# Cyan, Magenta, Yellow and Black
colors = "bgrcmyk"
# Number of algorithms to be plotted
num_algs = 2
#
if len(argv) != 2:
	print "Use ./stat.py [query | del | ins] to generate graphs"
	exit()
	
reading = argv[1]
plural = ""
if reading == "query":
	plural = "queries"
elif reading == "del":
开发者ID:YnkDK,项目名称:dynAlg14,代码行数:30,代码来源:stat.py


示例20: SkipTest

# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
import tempfile

import numpy as np

from nose import SkipTest
try:
    import matplotlib as mp
    # Make really sure that we don't try to open an Xserver connection.
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
except ImportError:
    raise SkipTest('Could not import matplotlib')

from ..activation_maps import demo_plot_map, plot_anat, plot_map
from ..anat_cache import mni_sform, _AnatCache



def test_demo_plot_map():
    # This is only a smoke test
    mp.use('svg', warn=False)
    import pylab as pl
    pl.switch_backend('svg')
    demo_plot_map()
    # Test the black background code path
    demo_plot_map(black_bg=True)

开发者ID:VirgileFritsch,项目名称:nipy,代码行数:29,代码来源:test_activation_maps.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pylab.text函数代码示例发布时间:2022-05-25
下一篇:
Python pylab.suptitle函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap