예제 #1
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._tri = None
            for key in default_kargs:
                if not obj.hasp(key): obj.setp(key, default_kargs[key])
                if not obj.hasvar(key): obj.setvar(key, default_kargs[key])
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('x', ['any'])
        #        p.set_default_list(default_kargs)
        p.add_key('alpha', 1.0)
        p.add_key('color', 'b')

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x', 'alpha', 'color'):
            obj.setvar(name, v[name])

        obj.setvar("kywds", kywds)

        return obj
예제 #2
0
파일: fig_hist.py 프로젝트: piScope/piScope
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._tri = None
            for key in default_kargs:
                if not obj.hasp(key): obj.setp(key, default_kargs[key])
                if not obj.hasvar(key): obj.setvar(key, default_kargs[key])
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('x', ['any'])
#        p.set_default_list(default_kargs)
        p.add_key('alpha', 1.0)
        p.add_key('color', 'b')        

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x','alpha','color'): 
            obj.setvar(name, v[name])

        obj.setvar("kywds", kywds)

        return obj
예제 #3
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []  # for debug....
            obj._data_extent = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('v', ['iter|nonstr', 'dynamic'])
        p.add_opt('idxset', None, ['numbers|nonstr', 'dynamic'])

        #p.add_key('cmap', None)

        if 'cz' in kywds and kywds['cz']:
            def_alpha = None
            def_ec = None
            def_fc = None
            def_lw = 0.0
        else:
            def_alpha = 1.0
            def_ec = (0, 0, 0, 1)
            def_fc = (0, 0, 1, 1)
            def_lw = 1.0

        # this prevent from passing linewidth to aritist
        def_lw = kywds.pop('linewidth', def_lw)
        p.add_key('linewidths', def_lw)

        p.add_key('alpha', def_alpha)
        p.add_key('facecolor', def_fc)
        p.add_key('edgecolor', def_ec)
        p.add_key('normals', None)
        p.add_key('cz', False, 'bool')
        p.add_key('cdata', None)
        p.add_key('shade', 'linear')
        p.add_key('array_idx', None)
        p.add_key('edge_idx', None)        
        p.add_key('use_pointfill', False)
        p.add_key('draw_last', False)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #4
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._mpl_cmd = 'plot'
            obj._eb_container = (None, tuple(), tuple())
            obj._other_artists = []
            obj._objs = []  # for debug....
            obj._data_extent = None
            obj._is_decimate = False
            obj._use_decimate = False
            obj._decimate_limit = _decimate_limit
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        mpl_cmd = kywds.pop('mpl_command', 'plot')
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_opt('z', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('s', '', 'str')  # optional argument
        p.add_key('cz', False, 'bool')

        #        if mpl_cmd is 'errorbar':
        p.add_key('xerr', None)
        p.add_key('yerr', None)
        p.add_key('ecolor', None)
        p.add_key('elinewidth', None)
        p.add_key('array_idx', None)
        if 'cz' in kywds and kywds['cz']:
            p.add_key('cmap', 'jet')
        p.add_key('c', None)

        p.set_ndconvert("x", "y", "z", "xerr", "yerr", "c")
        p.set_squeeze_minimum_1D("x", "y", "z", "xerr", "yerr", "c")
        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        obj._mpl_cmd = mpl_cmd
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1]).astype(v["y"].dtype)
        if 'cmap' in v and v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap):
                v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #5
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._tri = None
            for key in default_kargs:
                if not obj.hasp(key):
                    obj.setp(key, default_kargs[key])
                if not obj.hasvar(key):
                    obj.setvar(key, default_kargs[key])
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('x', ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_opt('z', None, ['numbers|nonstr'])
        p.add_key('s', 20)
        p.add_key('c', 'b', ['numbers', 'str'])
        p.add_key('marker', 'o')
        p.add_key('sscale', 1.0)
        p.set_ndconvert(
            "x",
            "y",
            "z",
        )
        p.set_squeeze_minimum_1D(
            "x",
            "y",
            "z",
        )
        #        p.set_default_list(default_kargs)
        p.add_key('alpha', 1.0)
        p.add_key('cmap', 'jet')

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x', 'y', 'z', 's', 'c', 'alpha', 'marker', 'sscale'):
            obj.setvar(name, v[name])
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap):
                v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        obj.setvar("kywds", kywds)

        return obj
예제 #6
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs=[]  ## for debug....     
            obj._data_extent=None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('v', ['iter|nonstr', 'dynamic']) 
        p.add_opt('idxset', None, ['numbers|nonstr', 'dynamic']) 

        #p.add_key('cmap', None)

        if 'cz' in kywds and kywds['cz']:
            def_alpha = None
            def_ec = None
            def_fc = None
            def_lw = 0.0
        else:
            def_alpha = 1.0
            def_ec = (0, 0, 0, 1)
            def_fc = (0, 0, 1, 1)
            def_lw = 1.0

        # this prevent from passing linewidth to aritist
        def_lw = kywds.pop('linewidth', def_lw)
        p.add_key('linewidths', def_lw)

        p.add_key('alpha', def_alpha)
        p.add_key('facecolor', def_fc)
        p.add_key('edgecolor', def_ec)
        p.add_key('normals', None)
        p.add_key('cz', False, 'bool')
        p.add_key('cdata', None)
        p.add_key('shade', 'linear')
        p.add_key('array_idx', None)
        p.add_key('use_pointfill', False)
        p.add_key('draw_last', False)

        v, kywds,d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #7
0
파일: fig_plot.py 프로젝트: piScope/piScope
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._mpl_cmd = 'plot'
            obj._eb_container = (None, tuple(), tuple())
            obj._other_artists = []
            obj._objs=[]  ## for debug....     
            obj._data_extent=None
            obj._is_decimate = False
            obj._use_decimate = False
            obj._decimate_limit = _decimate_limit
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        mpl_cmd = kywds.pop('mpl_command', 'plot')
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic']) 
        p.add_var('y', ['numbers|nonstr', 'dynamic'])       
        p.add_opt('z', None, ['numbers|nonstr', 'dynamic']) 
        p.add_opt('s', '', 'str')                ### optional argument
        p.add_key('cz', False, 'bool')

#        if mpl_cmd is 'errorbar':
        p.add_key('xerr', None)
        p.add_key('yerr', None)
        p.add_key('ecolor', None)
        p.add_key('elinewidth', None)
        p.add_key('array_idx', None)        
        if 'cz' in kywds and kywds['cz']:
            p.add_key('cmap', 'jet')
        p.add_key('c',  None)                           

        p.set_ndconvert("x","y","z","xerr","yerr", "c")
        p.set_squeeze_minimum_1D("x","y","z","xerr","yerr", "c")
        v, kywds,d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        obj._mpl_cmd = mpl_cmd
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1]).astype(v["y"].dtype)
        if 'cmap' in v and v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap): v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #8
0
    def __new__(cls, *args, **kywds):
        """
        quiver : quiver plot 
        quiver(U, V, **kargs)
        quiver(U, V, C, **kargs)
        quiver(X, Y, U, V, **kargs)
        quiver(X, Y, U, V, C, **kargs)
        """
        def set_hidden_vars(obj):
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('y', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('u', ['numbers|nonstr', 'dynamic'])
        p.add_var('v', ['numbers|nonstr', 'dynamic'])
        p.add_opt('c', None, ['numbers|nonstr', 'dynamic'])

        p.set_default_list(default_kargs)
        p.add_key2(("alpha", "cmap"))
        p.add_key2(("pivot", "pivot"))
        p.set_pair("x", "y")  # x and y should be given
        # together
        p.set_ndconvert("x", "y", "u", "v", "c")
#        p.set_squeeze_minimum_1D("x","y","z")

        v, kywds, d, flag = p.process(*args, **kywds)
        dprint2(d)

        if not flag:
            raise ValueError('Failed when processing argument')
            return None

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('u', 'v', 'c', 'x', 'y'):
            obj.setvar(name, v[name])
        for name in ('alpha', 'cmap', 'pivot'):
            obj.setvar(name, v[name])

        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']

        obj.setvar("kywds", kywds)
        return obj
예제 #9
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []  # for debug....
            obj._data_extent = None
            obj._coarse_artist = None
            obj._fine_artist = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['iter|nonstr', 'dynamic'])
        p.add_opt('y', None, ['iter|nonstr', 'dynamic'])
        p.add_var('z', ['iter|nonstr', 'dynamic'])

        p.add_key('cmap', None)
        p.add_key('shade', 'flat')
        p.add_key('linewidth', 1.0)
        p.add_key('alpha', None)
        p.add_key('rstride', 1)
        p.add_key('cstride', 1)
        p.add_key('edgecolor', 'k')
        p.add_key('facecolor', 'b')
        p.add_key('cz', not 'color' in kywds)
        p.add_key('cdata', None)

        p.set_pair("x", "y")
        p.set_ndconvert("x", "y", "z")
        p.set_squeeze_minimum_1D("x", "y", "z")

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)

        obj = set_hidden_vars(obj)
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap):
                v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']

        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #10
0
파일: fig_fill.py 프로젝트: piScope/piScope
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._mpl_cmd = 'fill'
            obj._data_extent = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        mpl_cmd, kywds = ProcessKeywords(kywds, 'mpl_command', 'fill')
        p = ArgsParser()

        if mpl_cmd == 'fill_betweenx':
            p.add_var('y', ['iter|nonstr', 'dynamic'])
            p.add_opt('x', None, ['iter|nonstr', 'dynamic'])
        else:
            p.add_opt('x', None, ['iter|nonstr', 'dynamic'])
            p.add_var('y', ['iter|nonstr', 'dynamic'])
        if mpl_cmd == 'fill':
            p.add_opt('s', '', 'str')

        p.add_key('x2', None)
        p.add_key('y2', None)
        p.add_key('where', None)
        p.add_key('edgecolor', 'black')
        p.add_key('linewidth', 1.0)
        p.add_key('linestyle', 'solid')
        p.add_key('alpha', 1)
        p.add_key('facecolor', 'blue')
        p.add_key('zs', 0)

        p.set_ndconvert("x", "y", "x2", "y2")

        v, kywds, d, flag = p.process(*args, **kywds)

        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        obj._mpl_cmd = mpl_cmd
        if v["x"] is None:
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #11
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs=[]  ## for debug....     
            obj._data_extent=None
            obj._coarse_artist = None
            obj._fine_artist = None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['iter|nonstr', 'dynamic']) 
        p.add_opt('y', None, ['iter|nonstr', 'dynamic'])       
        p.add_var('z', ['iter|nonstr', 'dynamic']) 


        p.add_key('cmap', None)
        p.add_key('shade', 'flat')
        p.add_key('linewidth', 1.0)
        p.add_key('alpha', None)
        p.add_key('rstride', 1)
        p.add_key('cstride', 1)
        p.add_key('edgecolor', 'k')        
        p.add_key('facecolor', 'b')
        p.add_key('cz',  not 'color' in kywds) 
        p.add_key('cdata', None)                

        p.set_pair("x", "y")
        p.set_ndconvert("x","y","z")
        p.set_squeeze_minimum_1D("x","y","z")

        v, kywds,d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        
        obj = set_hidden_vars(obj)
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap): v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']

        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #12
0
파일: fig_fill.py 프로젝트: piScope/piScope
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._mpl_cmd = 'fill'
            obj._data_extent=None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        mpl_cmd, kywds = ProcessKeywords(kywds, 'mpl_command', 'fill')
        p = ArgsParser()

        if mpl_cmd == 'fill_betweenx':
            p.add_var('y', ['iter|nonstr', 'dynamic'])       
            p.add_opt('x', None, ['iter|nonstr', 'dynamic']) 
        else:
            p.add_opt('x', None, ['iter|nonstr', 'dynamic']) 
            p.add_var('y', ['iter|nonstr', 'dynamic'])       
        if mpl_cmd == 'fill':
            p.add_opt('s', '', 'str')

        p.add_key('x2', None)
        p.add_key('y2', None)
        p.add_key('where', None)
        p.add_key('edgecolor', 'black')
        p.add_key('linewidth', 1.0)
        p.add_key('linestyle', 'solid')
        p.add_key('alpha', 1)
        p.add_key('facecolor', 'blue')
        p.add_key('zs', 0)

        p.set_ndconvert("x","y", "x2", "y2")

        v, kywds,d, flag = p.process(*args, **kywds)

        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        obj._mpl_cmd = mpl_cmd
        if v["x"] is None:
           v["x"] = np.arange(v["y"].shape[-1])
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #13
0
파일: fig_eps.py 프로젝트: piScope/piScope
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._image_size = (-1, -1)
            obj._image_scale_str = ('100', '100')
            obj._eps_bbox = (-1, -1, -1, -1)
            obj._image = None
            obj._image_artists = []
            obj._image_alpha = 1.0
            obj._image_scale = (1, 1)
            obj._keep_aspect = True
            obj._anchor_mode = (0,0) # 0 (left or bottom) 1 (center) 2 (right, top)
            obj._resize_mode = True  # True  use normalized coords.
                                     # False evaulate new size from the eps bbox
            return obj

        p = ArgsParser()
        p.add_opt('org_epsfile', None, 'str')
        p.add_opt('xy', [0.2, 0.2], 'numbers')

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('xy','org_epsfile'):
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #14
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._image_size = (-1, -1)
            obj._image_scale_str = ('100', '100')
            obj._eps_bbox = (-1, -1, -1, -1)
            obj._image = None
            obj._image_artists = []
            obj._image_alpha = 1.0
            obj._image_scale = (1, 1)
            obj._keep_aspect = True
            obj._anchor_mode = (
                0, 0)  # 0 (left or bottom) 1 (center) 2 (right, top)
            obj._resize_mode = True  # True  use normalized coords.
            # False evaulate new size from the eps bbox
            return obj

        p = ArgsParser()
        p.add_opt('org_epsfile', None, 'str')
        p.add_opt('xy', [0.2, 0.2], 'numbers')

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('xy', 'org_epsfile'):
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #15
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'):
                obj._tri = None  # this can go away!?
            for key in default_kargs:
                if not obj.hasp(key):
                    obj.setp(key, default_kargs[key])
                if not obj.hasvar(key):
                    obj.setvar(key, default_kargs[key])
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('y', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('z', ['numbers|nonstr', 'dynamic'])
        p.set_pair("x", "y")  # x and y should be given
        # together
        p.set_ndconvert("x", "y", "z")
        p.set_squeeze_minimum_1D("x", "y", "z")
        p.set_default_list(default_kargs)
        p.add_key2(('use_tri', 'interp', 'shading', 'alpha'))
        p.add_key('cmap', 'jet')

        v, kywds, d, flag = p.process(*args, **kywds)
        
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x', 'y', 'z', 'use_tri', 'interp', 'shading', 'alpha'):
            obj.setvar(name, v[name])
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap):
                v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        obj.setvar("kywds", kywds)

        return obj
예제 #16
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'):
                obj._tri = None  # this can go away!?
            for key in default_kargs:
                if not obj.hasp(key):
                    obj.setp(key, default_kargs[key])
                if not obj.hasvar(key):
                    obj.setvar(key, default_kargs[key])
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('t', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('v', ['numbers|nonstr', 'dynamic'])

        p.set_ndconvert("v", "t")
        p.set_squeeze_minimum_1D("v", "t")
        p.set_default_list(default_kargs)
        p.add_key2(('interp', 'shading', 'alpha', 'window', 'NFFT', 'noverlap',
                    'sides', 'detrend', 'pad_to'))
        p.add_key2('cmap', 'str')
        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        for name in (
                'v',
                't',
                'interp',
                'shading',
                'alpha',
        ):
            obj.setvar(name, v[name])
        obj.setp("use_tri", False)
        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']
        obj.setvar("kywds", kywds)
        return obj
예제 #17
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._tri = None
            for key in default_kargs:
                if not obj.hasp(key): obj.setp(key, default_kargs[key])
                if not obj.hasvar(key): obj.setvar(key, default_kargs[key])
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('x', ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_opt('z', None, ['numbers|nonstr'])
        p.add_key('s', 20)
        p.add_key('c', 'b', ['numbers', 'str'])
        p.add_key('marker', 'o')
        p.add_key('sscale', 1.0)        
        p.set_ndconvert("x","y","z",)     
        p.set_squeeze_minimum_1D("x","y","z", )
#        p.set_default_list(default_kargs)
        p.add_key('alpha', 1.0)
        p.add_key('cmap', 'jet')           

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x','y', 'z', 's', 'c', 'alpha',  'marker', 'sscale'): 
            obj.setvar(name, v[name])
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap): v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        obj.setvar("kywds", kywds)

        return obj
예제 #18
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'): obj._tri = None ## this can go away!?
            for key in default_kargs:
                if not obj.hasp(key): obj.setp(key, default_kargs[key])
                if not obj.hasvar(key): obj.setvar(key, default_kargs[key])
            return obj


        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('y', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('z', ['numbers|nonstr', 'dynamic'])
        p.set_pair("x", "y")    ### x and y should be given
                                ### together
        p.set_ndconvert("x","y","z")     
        p.set_squeeze_minimum_1D("x","y","z")
        p.set_default_list(default_kargs)
        p.add_key2(('use_tri', 'interp', 'shading', 'alpha'))
        p.add_key('cmap', 'jet')           

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x','y', 'z', 'use_tri', 'interp', 'shading', 'alpha'): 
            obj.setvar(name, v[name])
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap): v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        obj.setvar("kywds", kywds)

        return obj
예제 #19
0
    def __new__(cls, *args, **kywds):
        if len(args) == 3:
            tri = args[0]
            args = args[1:]
        else:
            tri = None

        def set_hidden_vars(obj):
            obj._other_artists = []
            obj._objs = []  # for debug....
            obj._data_extent = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_key('color', 'b')
        p.add_key('linestyle', '-')
        p.add_key('linewidth', 1.0)
        p.set_ndconvert("x", "y")
        p.set_squeeze_minimum_1D("x", "y")
        p.add_key('mask', None)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        obj.setvar("tri", tri)

        return obj
예제 #20
0
    def __new__(cls, *args, **kywds):
        """
        FigAxline([x1,x2,x3...], [y1,y2,...])
        x is for vertical line
        y is for horizontal line
        """
        def set_hidden_vars(obj):
            obj._objs=[]  ## for debug....
            obj._drag_backup = None
            obj._drag_delta = None
            obj._data_extent=None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', [], ['numbers|nonstr', 'dynamic', 'real', 'empty'])
        p.add_opt('y', [], ['numbers|nonstr', 'dynamic', 'real', 'empty'])
        p.set_ndconvert("x","y")
        p.add_key('draggable', False)


        v, kywds,d, flag = p.process(*args, **kywds)
        if isinstance(v["x"], float) or isinstance(v["x"], int) :
           v["x"] = [v["x"]]
        if isinstance(v["y"], float) or isinstance(v["y"], int) :
           v["y"] = [v["y"]]

        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)        

        return obj
예제 #21
0
    def __new__(cls, *args, **kywds):
        """
        FigAxline([x1,x2,x3...], [y1,y2,...])
        x is for vertical line
        y is for horizontal line
        """
        def set_hidden_vars(obj):
            obj._objs = []  ## for debug....
            obj._drag_backup = None
            obj._drag_delta = None
            obj._data_extent = None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', [], ['numbers|nonstr', 'dynamic', 'real', 'empty'])
        p.add_opt('y', [], ['numbers|nonstr', 'dynamic', 'real', 'empty'])
        p.set_ndconvert("x", "y")
        p.add_key('draggable', False)

        v, kywds, d, flag = p.process(*args, **kywds)
        if isinstance(v["x"], float) or isinstance(v["x"], int):
            v["x"] = [v["x"]]
        if isinstance(v["y"], float) or isinstance(v["y"], int):
            v["y"] = [v["y"]]

        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        for name in v.keys():
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)

        return obj
예제 #22
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []
            obj._drag_backup = None
            obj._drag_delta = None
            obj._drag_mode = 0
            obj._data_extent = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', [], ['can_ndreal_array|nonstr', 'dynamic', 'empty'])
        p.add_opt('y', [], ['can_ndreal_array|nonstr', 'dynamic', 'empty'])
        p.add_key('draggable', True)
        p.set_ndconvert("x", "y")
        v, kywds, d, flag = p.process(*args, **kywds)

        # special check for x and y
        if not 'x' in v:
            raise ValueError('can not parse arguments')
        if not 'y' in v:
            raise ValueError('can not parse arguments')
        v["x"], flag2 = _special_xy_check(v["x"])
        v["y"], flag3 = _special_xy_check(v["y"])

        if not flag or not flag2 or not flag3:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)

        obj = set_hidden_vars(obj)
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)

        return obj
예제 #23
0
    def __new__(cls, *args, **kywds):
        if len(args) == 3:
            tri = args[0]            
            args = args[1:]
        else:
            tri = None
            
        def set_hidden_vars(obj):
            obj._other_artists = []
            obj._objs=[]  ## for debug....     
            obj._data_extent=None
            return obj
        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic']) 
        p.add_var('y', ['numbers|nonstr', 'dynamic'])       
        p.add_key('color', 'b')
        p.add_key('linestyle', '-')
        p.add_key('linewidth', 1.0)
        p.set_ndconvert("x","y")
        p.set_squeeze_minimum_1D("x","y")
        p.add_key('mask', None)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds) 
        obj.setvar("tri", tri) 

        return obj
예제 #24
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []  # for debug....
            obj._hit_idx = -1
            obj._hit_seg = -1
            obj._hit_artist = -1
            obj._mesh = 10
            obj._data_extent = None
            obj._data_extent_checked = False
            obj._sp_interp = 1
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])

        p.set_ndconvert("x", "y")
        p.set_squeeze_minimum_1D("x", "y")

        p.add_key('draggable', True)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        if v["x"] is None:
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #25
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs=[]  ## for debug....
            obj._hit_idx = -1
            obj._hit_seg = -1
            obj._hit_artist = -1
            obj._mesh = 10
            obj._data_extent=None
            obj._data_extent_checked=False
            obj._sp_interp = 1
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic']) 
        p.add_var('y', ['numbers|nonstr', 'dynamic'])       

        p.set_ndconvert("x","y")
        p.set_squeeze_minimum_1D("x","y")

        p.add_key('draggable', True)

        v, kywds,d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        if v["x"] is None:
           v["x"] = np.arange(v["y"].shape[-1])
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
예제 #26
0
파일: fig_spec.py 프로젝트: piScope/piScope
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'): obj._tri = None ## this can go away!?            
            for key in default_kargs:
                if not obj.hasp(key): obj.setp(key, default_kargs[key])
                if not obj.hasvar(key): obj.setvar(key, default_kargs[key])
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('t', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('v', ['numbers|nonstr', 'dynamic'])

        p.set_ndconvert("v", "t")     
        p.set_squeeze_minimum_1D("v","t")
        p.set_default_list(default_kargs)
        p.add_key2(( 'interp', 'shading', 'alpha', 'window', 'NFFT', 
                     'noverlap', 'sides', 'detrend', 'pad_to'))
        p.add_key2('cmap', 'str')
        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        for name in ('v', 't', 'interp', 'shading', 'alpha',): 
            obj.setvar(name, v[name])
        obj.setp("use_tri", False)
        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']
        obj.setvar("kywds", kywds)
        return obj
예제 #27
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs=[]
            obj._drag_backup=None
            obj._drag_delta = None
            obj._drag_mode=0
            obj._data_extent=None
            return obj
        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', [], ['can_ndreal_array|nonstr', 'dynamic', 'empty'])
        p.add_opt('y', [], ['can_ndreal_array|nonstr', 'dynamic', 'empty'])
        p.add_key('draggable', True)
        p.set_ndconvert("x","y")
        v, kywds,d, flag = p.process(*args, **kywds)

        ### special check for x and y
        if not 'x' in v: raise ValueError('can not parse arguments')
        if not 'y' in v: raise ValueError('can not parse arguments')
        v["x"], flag2 = _special_xy_check(v["x"])
        v["y"], flag3 = _special_xy_check(v["y"])

        if not flag or not flag2 or not flag3: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)

        obj = set_hidden_vars(obj)
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)        

        return obj
예제 #28
0
    def __new__(cls, *args, **kywds):
        """
        quiver(X, Y, Z, U, V, W, **kwargs)
        """
        def set_hidden_vars(obj):
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        if 'cz' in kywds and kywds['cz']:
            def_alpha = None
            def_ec = None
            def_fc = None
            def_lw = 0.0
        else:
            def_alpha = 1.0
            def_ec = (0, 0, 0, 1)
            def_fc = (0, 0, 1, 1)
            def_lw = 1.0

        p = ArgsParser()
        p.add_var('x', ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_var('z', ['numbers|nonstr', 'dynamic'])
        p.add_var('u', ['numbers|nonstr', 'dynamic'])
        p.add_var('v', ['numbers|nonstr', 'dynamic'])
        p.add_var('w', ['numbers|nonstr', 'dynamic'])
        p.add_key('cz', False, 'bool')
        p.add_key('cdata', None)
        p.set_default_list(default_kargs)
        p.add_key2(("cmap"))
        p.add_key2(("pivot", "pivot"))
        p.add_key("length", 1.0)
        p.add_key("arrow_length_ratio", 0.3)
        p.add_key('alpha', def_alpha)
        p.add_key('facecolor', def_fc)
        p.add_key('edgecolor', def_ec)

        p.set_ndconvert("x", "y", "z", "u", "v", "w", "c")

        v, kywds, d, flag = p.process(*args, **kywds)
        dprint2(d)

        if not flag:
            raise ValueError('Failed when processing argument')
            return None

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('u', 'v', 'w', 'x', 'y', 'z'):
            obj.setvar(name, v[name])
        for name in ('alpha', 'cmap', 'pivot', 'length', 'arrow_length_ratio',
                     'cz', 'cdata', 'facecolor', 'edgecolor'):
            obj.setvar(name, v[name])

        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']

        obj.setvar("kywds", kywds)
        return obj
예제 #29
0
파일: fig_grp.py 프로젝트: piScope/piScope
 def __new__(cls, *args, **kargs):
     obj = FigObj.__new__(cls, *args, **kargs)
     obj._artist_extent = [None]*4
     return obj
예제 #30
0
 def __new__(cls, *args, **kargs):
     obj = FigObj.__new__(cls, *args, **kargs)
     obj._artist_extent = [None] * 4
     return obj
예제 #31
0
    def __new__(cls, *args, **kywds):
        """
        contour : contour plot 
        contour(z, n)  
        contour(x, y, z, n)  
        contour(z, v)  
        contour(x, y, z, v)  

        n: number of levels
        v: a list of contour levels
        """
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'): obj._tri = None ## this can go away!?
            obj._clabels = []
            obj._clabel_param = def_clabel_param 
            obj._nouse_expression = False 
            obj._hit_path = None
            obj._expression = ''
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr','dynamic'])
        p.add_opt('y', None, ['numbers|nonstr','dynamic'])
        p.add_var('z', ['numbers|nonstr','dynamic'])
        p.add_opt('n', 7, 'int')              ### n = number of levels
        p.add_opt('v', None, ['numbers|nonstr', 'dynamic'])   ### v = levels (array)

        p.set_default_list(default_kargs)
        p.add_key2(("FillMode", "alpha"))
        p.add_key2('interp', 'str')
        p.add_key2('cmap', 'str')
        p.add_key('offset', None)
        p.add_key('zdir', 'z')

        p.set_pair("x", "y")                     ### x and y should be given
                                                 ### together
        p.set_ndconvert("x","y","z") 
        p.set_squeeze_minimum_1D("x","y","z")

        v, kywds, d, flag = p.process(*args, **kywds)
        dprint2(d) 

        if not flag: 
            raise ValueError('Failed when processing argument')
            return None


        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        obj._set_expression_vars(v['v'])
        for name in ('x','y', 'z'): 
            obj.setvar(name, v[name])
        for name in ('FillMode','alpha', 'n', 'v', "cmap", "offset", "zdir"): 
            obj.setvar(name, v[name])

        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']

        obj.setvar("kywds", kywds)
        return obj
예제 #32
0
    def __new__(cls, *args, **kywds):
        """
        contour : contour plot 
        contour(z, n)  
        contour(x, y, z, n)  
        contour(z, v)  
        contour(x, y, z, v)  

        n: number of levels
        v: a list of contour levels
        """
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'): obj._tri = None  ## this can go away!?
            obj._clabels = []
            obj._clabel_param = def_clabel_param
            obj._nouse_expression = False
            obj._hit_path = None
            obj._expression = ''
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('y', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('z', ['numbers|nonstr', 'dynamic'])
        p.add_opt('n', 7, 'int')  ### n = number of levels
        p.add_opt('v', None,
                  ['numbers|nonstr', 'dynamic'])  ### v = levels (array)

        p.set_default_list(default_kargs)
        p.add_key2(("FillMode", "alpha"))
        p.add_key2('interp', 'str')
        p.add_key2('cmap', 'str')
        p.add_key('offset', None)
        p.add_key('zdir', 'z')

        p.set_pair("x", "y")  ### x and y should be given
        ### together
        p.set_ndconvert("x", "y", "z")
        p.set_squeeze_minimum_1D("x", "y", "z")

        v, kywds, d, flag = p.process(*args, **kywds)
        dprint2(d)

        if not flag:
            raise ValueError('Failed when processing argument')
            return None

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        obj._set_expression_vars(v['v'])
        for name in ('x', 'y', 'z'):
            obj.setvar(name, v[name])
        for name in ('FillMode', 'alpha', 'n', 'v', "cmap", "offset", "zdir"):
            obj.setvar(name, v[name])

        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']

        obj.setvar("kywds", kywds)
        return obj