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

Python pylab.connect函数代码示例

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

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



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

示例1: __init__

    def __init__(self, data, auto_mask, savedir):
        self.savedir = savedir
        self.fig = pylab.figure()
        self.ax = self.fig.add_subplot(111)
        self.ax.set_title('Select ROI to mask. Press \'m\' to mask, \'u\' to unmask or \'w\' to save and exit ')
        self.canvas = self.ax.figure.canvas
        #self.data = n.log10(data)
        self.data = data
        self.lx, self.ly = shape(self.data)
        self.mask = auto_mask
        self.masked_data = numpy.ma.masked_array(self.data,self.mask)
        self.points = []
        self.key = []
        self.x = 0
        self.y = 0
        self.xy = []
        self.xx = []
        self.yy = []
        self.ind = 0
        self.img = self.ax.imshow(self.masked_data,origin='lower',interpolation='nearest',animated=True)
        self.lc,=self.ax.plot((0,0),(0,0),'-+w',color='black',linewidth=1.5,markersize=8,markeredgewidth=1.5)
        self.lm,=self.ax.plot((0,0),(0,0),'-+w',color='black',linewidth=1.5,markersize=8,markeredgewidth=1.5)
        self.ax.set_xlim(0,self.lx)
        self.ax.set_ylim(0,self.ly)
        for i in range(self.lx):
            for j in range(self.ly):
                self.points.append([i,j])

        cidb = pylab.connect('button_press_event', self.on_click)
        cidk = pylab.connect('key_press_event',self.on_click)
        cidm = pylab.connect('motion_notify_event',self.on_move)
开发者ID:pawel-kw,项目名称:pyxsvs,代码行数:31,代码来源:pyxsvs.py


示例2: plot_box

def plot_box(x, y, nbins=10, c=None, s=None, label=None, info=None, alpha=1.0,
                 marker='o', vmin=None, vmax=None, legend=True):
    # x, y, c, s = rand(4, 100)
    fig = figure()
    ax = fig.add_subplot(111)
    (hist, bins) = np.histogram(x, bins=nbins)
    ind = np.digitize(x, bins)
    data = []
    positions = []
    for i in range(1, nbins+1):
        y_slice = y[ind == i]
        if y_slice.size > 10:
            # y_mean = np.median(y_slice)
            # y_upper = np.percentile(y_slice, 75)
            # y_lower = np.percentile(y_slice, 25)
            # data.append((y_mean, y_mean, y_upper, y_lower))
            data.append(y_slice)
            positions.append((bins[i-1] + bins[i])/2)

    if legend:
        ax.boxplot(data, positions=[round(p,2) for p in positions], widths=0.055)
        ax.set_xlim(0,0.5)
    else:
        scatter(x, y, 100*s, c, alpha=alpha, marker=marker, vmin=vmin,
                vmax=vmax, label='_nolegend_')

    #fig.savefig('pscoll.eps')
    if label is not None:
        af = AnnoteFinder(x, y, label, info=info)
        connect('button_press_event', af)
开发者ID:megacell,项目名称:traffic-estimation-comparison,代码行数:30,代码来源:plotting_utils.py


示例3: test

def test():
    x = range(10)
    y = range(10)
    annotes = ['a', 'b', 'c', 'd', 'GRB1010101', 'f', 'g', 'h', 'i', 'j']

    scatter(x,y)
    af =  AnnoteFinder(x,y, annotes)
    connect('button_press_event', af)
开发者ID:qmorgan,项目名称:qsoft,代码行数:8,代码来源:Annote.py


示例4: testcolor

def testcolor():
    x = range(10)
    y = range(10)
    z = range(10)
    annotes = ['a', 'b', 'c', 'd', 'GRB1010101', 'f', 'g', 'h', 'i', 'j']

    from Plotting import ColorScatter
    ColorScatter.ColorScatter(x,y,z,cmap='cool')
    af =  AnnoteFinder(x,y, annotes)
    connect('button_press_event', af)
开发者ID:qmorgan,项目名称:qsoft,代码行数:10,代码来源:Annote.py


示例5: labelindex

def labelindex(i,x,y,ax,display=False): 
    if ax==None:
        ax=plt.gca()
    indexstrings = [str(ind) for ind in i]
    if display ==True:
        for i in zip(indexstrings,x,y):
            print i
    af = AnnoteFinder(x,y,indexstrings,axis=ax)
    pylab.connect('button_press_event', af)
    return
开发者ID:CaptainAL,项目名称:Fagaalu-Sediment-Flux,代码行数:10,代码来源:SedFlux_Nuuuli.py


示例6: __init__

    def __init__(self, data, auto_mask, savedir):
        '''The constructor initializes all the variables and creates the plotting window.

        **Input arguments:**

            - *data*: NxM array
                The background to be masked - an averaged (static) scattering image.

            - *auto_mask*: NxM array
                The default mask, masking all the bad pixels.

            - *savedir*: string
                Directory where the mask file will be saved.
        '''
        self.mask_saved = False
        self.savedir = savedir
        self.fig = figure()
        title('Select ROI to mask. Press m to mask or w to save and exit ')
        self.ax = self.fig.add_subplot(111)
        # Check button for logscale switching
        self.cbax = self.fig.add_axes([0.01, 0.8, 0.1, 0.15])
        self.cb_log = CheckButtons(self.cbax, ('log',), (False,))
        self.cb_log.on_clicked(self.toggle_logscale)
        self.log_flag = False
        self.canvas = self.ax.figure.canvas
        #self.data = n.log10(data)
        self.raw_data = data.copy()
        self.data = data
        self.lx, self.ly = shape(self.data)
        self.auto_mask = auto_mask
        self.mask = auto_mask
        self.masked_data = n.ma.masked_array(self.data,self.mask)
        self.points = []
        self.key = []
        self.x = 0
        self.y = 0
        self.xy = []
        self.xx = []
        self.yy = []
        self.ind = 0
        self.img = self.ax.imshow(self.masked_data,origin='lower',interpolation='nearest',animated=True)
        self.colorbar = colorbar(self.img,ax=self.ax)
        self.lc,=self.ax.plot((0,0),(0,0),'-+w',color='black',linewidth=1.5,markersize=8,markeredgewidth=1.5)
        self.lm,=self.ax.plot((0,0),(0,0),'-+w',color='black',linewidth=1.5,markersize=8,markeredgewidth=1.5)
        self.ax.set_xlim(0,self.lx)
        self.ax.set_ylim(0,self.ly)
        for i in range(self.lx):
            for j in range(self.ly):
                self.points.append([i,j])

        cidb = connect('button_press_event', self.on_click)
        cidk = connect('key_press_event',self.on_click)
        cidm = connect('motion_notify_event',self.on_move)
开发者ID:pawel-kw,项目名称:pyxsvs,代码行数:53,代码来源:makemask.py


示例7: main

def main():

    parser = argparse.ArgumentParser(description='')
    parser.add_argument('--MC','-Q', help='Quantum training file',   nargs='+')
    parser.add_argument('--ED','-C', help='Classical training file', nargs='+')
    parser.add_argument('--clamped', help='Clamped simulation', default=False, action='store_true')
    args = vars(parser.parse_args())


    if 'MC' in args.keys():
        skip = 3 # skip estimators we don't care about 
        for filename in args['MC']:
            fparams = ssexyhelp.getReduceParamMap(filename)
            data    = np.loadtxt(filename)
            headers = Hfile.getHeaders(filename)
            if not(args['clamped']): (first, last) = (headers.index('X0'),  headers.index('sX0'))
            else:                    (first, last) = (headers.index('sX0'), len(headers))
            aves    = np.zeros(last-first)
            stds    = np.zeros(last-first)
            for i, c in enumerate(range(first, last)):
                cdata   = data[~np.isnan(data[:,c]),c]
                aves[i] = np.mean(cdata)
                stds[i] = np.amax(MCstat.bin(cdata[np.newaxis].T))
            
    if 'ED' in args.keys():
        for filename in args['ED']:
            fparams = ssexyhelp.getReduceParamMap(filename)
            ED    = np.loadtxt(filename)
    
    print ED
    print aves
    print stds
    colors = ["#66CAAE", "#CF6BDD", "#E27844", "#7ACF57", "#92A1D6", "#E17597", "#C1B546"]


    fig = pl.figure(1, figsize=(10,5))
    pl.connect('key_press_event',kevent.press)
    ax  = pl.subplot(111)
    ax.plot((ED-aves)/stds, color=colors[0])#, lw=2, m='o', ls='')#, label=r'$data$')
    
    pl.ylabel(r'$(ED-MC)/\Delta_{MC}$')
    pl.xlabel(r'$Averages$')
    lgd = pl.legend(loc = 'best')
    
    lheaders = []
    for head in Hfile.getHeaders(args['ED'][0]):
        lheaders += [r'$%s$' %head]
    pl.xticks(range(len(lheaders)), lheaders, rotation='vertical')

    #lgd.draggable(state=True)
    #lgd.draw_frame(False)
    pl.tight_layout()
    pl.show()
开发者ID:BohdanKul,项目名称:Scripts,代码行数:53,代码来源:MC_test.py


示例8: __init__

    def __init__(self, ax, cursor='vertical'):
        # cursor can be vertical, horizontal or cross
        self.ax = ax
        self.lx = None; self.ly = None
        self.cursor = cursor

        if cursor != 'vertical':
            self.lx = ax.axhline(color='k')  # the horiz line
        if cursor != 'horizontal':
            self.ly = ax.axvline(color='k')  # the vert line

        pylab.connect('motion_notify_event', self.mouse_move)
        pylab.connect('button_press_event', self.mouse_click)
开发者ID:Basildcruz,项目名称:ecgtk,代码行数:13,代码来源:ecgtk.py


示例9: plot_scatter

def plot_scatter(x, y, c=None, s=None, label=None, info=None, alpha=1.0,
                 marker='o', vmin=None, vmax=None, legend=True):
    # x, y, c, s = rand(4, 100)
    if legend:
        scatter(x, y, 100*s, c, alpha=alpha, marker=marker, vmin=vmin,
                vmax=vmax)
    else:
        scatter(x, y, 100*s, c, alpha=alpha, marker=marker, vmin=vmin,
                vmax=vmax, label='_nolegend_')
    #fig.savefig('pscoll.eps')
    if label is not None:
        af = AnnoteFinder(x, y, label, info=info)
        connect('button_press_event', af)
开发者ID:megacell,项目名称:traffic-estimation-comparison,代码行数:13,代码来源:plotting_utils.py


示例10: main

def main(): 
    parser = argparse.ArgumentParser(description='')
    parser.add_argument('--quant', '-Q', help='Quantum training file',   nargs='+')
    parser.add_argument('--class', '-C', help='Classical training file', nargs='+')

    args = vars(parser.parse_args())

    colors = ["#66CAAE", "#CF6BDD", "#E27844", "#7ACF57", "#92A1D6", "#E17597", "#C1B546"]
    #fig = pl.figure(1, figsize=(10,5))
    f, (ax1, ax2)  = pl.subplots(2)
    pl.connect('key_press_event',kevent.press)

    # ----------------------------------------------------------------------
    cdata = {}
    for filename in args['class']:
        data = np.loadtxt(filename)
        LL      = np.amin(data[1:,0])
        seed = int(filename[:-4].split('_')[-1])
        cdata[seed] = LL

    # ----------------------------------------------------------------------
    qdata = {}
    for filename in args['quant']:
        data = np.loadtxt(filename)
        LL      = np.amin(data[1:,0])
        seed = int(filename[:-4].split('_')[-1])
        qdata[seed] = LL
    
    # ----------------------------------------------------------------------
    cLL   = []
    qLL   = []
    for cseed in cdata.keys():
        if cseed in qdata.keys():
            cLL += [cdata[cseed]]
            qLL += [qdata[cseed]]
    cLL = np.array(cLL)
    qLL = np.array(qLL)
    ax1.scatter(cLL, qLL)
    ax1.set_xlabel(r'$LL_{class}$')
    ax1.set_ylabel(r'$LL_{quant}$')
    
    ax2.scatter(cLL, cLL-qLL)
    ax2.set_xlabel(r'$Classical \, LL$')
    ax2.set_ylabel(r'$LL_{class} - LL_{quant}$')
    
    #lgd = pl.legend(loc = 'best')
    #lgd.draggable(state=True)
    #lgd.draw_frame(False)
    pl.tight_layout()
    pl.show()
开发者ID:BohdanKul,项目名称:Scripts,代码行数:50,代码来源:LLcorr.py


示例11: logplot

    def logplot(self, show_sliceplots=True):
        from zoom_colorbar import zoom_colorbar
        x_min = self.params['x_min']
        x_max = self.params['x_max']
        y_min = self.params['y_min']
        y_max = self.params['y_max']
        self.show_data = zeros((self.params['x_steps'],self.params['y_steps']))

        self.minimum_intensity = inf
        for j in range(self.params['y_steps']):
            for i in range(self.params['x_steps']):
                avg = self.bin_data[i,j,3]
                if avg > 0.0:
                    self.show_data[i,j] = avg
                else:
                    self.show_data[i,j] = 0.0
                if (avg < self.minimum_intensity and avg > 0):
                    self.minimum_intensity = avg

        #self.show_data = transpose(log(self.show_data + self.minimum_intensity / 2.0))

        fig = figure()
        self.fig = fig
        connect('pick_event', self.log_lin_select)

        if show_sliceplots:
            ax = fig.add_subplot(221, label='qxqz_plot')
            fig.sx = fig.add_subplot(222, label='sx', picker=True)
            fig.sx.xaxis.set_picker(True)
            fig.sx.yaxis.set_picker(True)
            fig.sz = fig.add_subplot(223, label='sz', picker=True)
            fig.sz.xaxis.set_picker(True)
            fig.sz.yaxis.set_picker(True)
            self.RS = RectangleSelector(ax, self.onselect, drawtype='box', useblit=True)
            fig.slice_overlay = None
        else:
            ax = fig.add_subplot(111, label='qxqz_plot')
        fig.ax = ax
        ax.set_title(self.params['description'])
        connect('key_press_event', self.toggle_selector)
        transformed_show_data = transpose(log(self.show_data + self.minimum_intensity / 2.0))
        im = ax.imshow(transformed_show_data, interpolation='nearest', aspect='auto', origin='lower',cmap=cm.jet, extent=(x_min,x_max,y_min,y_max))
        fig.im = im
        ax.set_xlabel(self.xlabel)
        ax.set_ylabel(self.ylabel)
        zoom_colorbar(im)
        figure(fig.number)
        fig.canvas.draw()
        return im
开发者ID:reflectometry,项目名称:osrefl,代码行数:49,代码来源:binned_data.py


示例12: __init__

    def __init__(self, datatype, filename, options):
        self.hfile = open(filename, "r")
        self.block_length = options.block
        self.start = options.start
        self.sample_rate = options.sample_rate
        self.psdfftsize = options.psd_size
        self.specfftsize = options.spec_size

        self.dospec = options.enable_spec  # if we want to plot the spectrogram

        self.datatype = datatype
        if self.datatype is None:
            self.datatype = datatype_lookup[options.data_type]
        self.sizeof_data = self.datatype().nbytes    # number of bytes per sample in file

        self.axis_font_size = 16
        self.label_font_size = 18
        self.title_font_size = 20
        self.text_size = 22

        # Setup PLOT
        self.fig = figure(1, figsize=(16, 12), facecolor='w')
        rcParams['xtick.labelsize'] = self.axis_font_size
        rcParams['ytick.labelsize'] = self.axis_font_size

        self.text_file     = figtext(0.10, 0.95, ("File: %s" % filename),
                                     weight="heavy", size=self.text_size)
        self.text_file_pos = figtext(0.10, 0.92, "File Position: ",
                                     weight="heavy", size=self.text_size)
        self.text_block    = figtext(0.35, 0.92, ("Block Size: %d" % self.block_length),
                                     weight="heavy", size=self.text_size)
        self.text_sr       = figtext(0.60, 0.915, ("Sample Rate: %.2f" % self.sample_rate),
                                     weight="heavy", size=self.text_size)
        self.make_plots()

        self.button_left_axes = self.fig.add_axes([0.45, 0.01, 0.05, 0.05], frameon=True)
        self.button_left = Button(self.button_left_axes, "<")
        self.button_left_callback = self.button_left.on_clicked(self.button_left_click)

        self.button_right_axes = self.fig.add_axes([0.50, 0.01, 0.05, 0.05], frameon=True)
        self.button_right = Button(self.button_right_axes, ">")
        self.button_right_callback = self.button_right.on_clicked(self.button_right_click)

        self.xlim = numpy.array(self.sp_iq.get_xlim())

        self.manager = get_current_fig_manager()
        connect('draw_event', self.zoom)
        connect('key_press_event', self.click)
        show()
开发者ID:dl1ksv,项目名称:gnuradio,代码行数:49,代码来源:plot_psd_base.py


示例13: createInteractivePlot

def createInteractivePlot(screen, refs, rho):
    global ip_refs, ip_xray, ip_rho, ip_rx, ip_ry
    ip_refs  = refs
    ip_xray  = screen
    ip_rho   = rho 

    ip_rx, ip_ry = [0],[0]
    ip_rx[-1] = (1550/FF,2040/FF)
    ip_ry[-1] = (1550/FF,2040/FF)

    ip_fig   = pl.figure(figsize=(0.7*5.12*2, 0.7*6.12*1))
    ip_fxray = pl.subplot(121)
    ip_freal = pl.subplot(122)
    ip_toggle_selector.RS = RectangleSelector(ip_fxray,line_select_callback,drawtype='box',useblit=True, button=[1,3])
    pl.connect('key_press_event', ip_toggle_selector)
    update_plot()
开发者ID:mattbierbaum,项目名称:cuda-plasticity,代码行数:16,代码来源:diffraction_pattern.py


示例14: __init__

    def __init__(self, datatype, filenames, options):
        self.hfile = list()
        self.legend_text = list()
        for f in filenames:
            self.hfile.append(open(f, "r"))
            self.legend_text.append(f)

        self.block_length = options.block
        self.start = options.start
        self.sample_rate = options.sample_rate

        self.datatype = datatype
        if self.datatype is None:
            self.datatype = datatype_lookup[options.data_type]
        self.sizeof_data = self.datatype().nbytes    # number of bytes per sample in file

        self.axis_font_size = 16
        self.label_font_size = 18
        self.title_font_size = 20
        self.text_size = 22

        # Setup PLOT
        self.fig = figure(1, figsize=(16, 9), facecolor='w')
        rcParams['xtick.labelsize'] = self.axis_font_size
        rcParams['ytick.labelsize'] = self.axis_font_size

        self.text_file_pos = figtext(0.10, 0.88, "File Position: ", weight="heavy", size=self.text_size)
        self.text_block    = figtext(0.40, 0.88, ("Block Size: %d" % self.block_length),
                                     weight="heavy", size=self.text_size)
        self.text_sr       = figtext(0.60, 0.88, ("Sample Rate: %.2f" % self.sample_rate),
                                     weight="heavy", size=self.text_size)
        self.make_plots()

        self.button_left_axes = self.fig.add_axes([0.45, 0.01, 0.05, 0.05], frameon=True)
        self.button_left = Button(self.button_left_axes, "<")
        self.button_left_callback = self.button_left.on_clicked(self.button_left_click)

        self.button_right_axes = self.fig.add_axes([0.50, 0.01, 0.05, 0.05], frameon=True)
        self.button_right = Button(self.button_right_axes, ">")
        self.button_right_callback = self.button_right.on_clicked(self.button_right_click)

        self.xlim = self.sp_f.get_xlim()

        self.manager = get_current_fig_manager()
        connect('key_press_event', self.click)
        show()
开发者ID:dl1ksv,项目名称:gnuradio,代码行数:46,代码来源:plot_data.py


示例15: plot

    def plot(self, lat=0., lon=0., bigmap=False, ax=None, show=True, draw_countries=True, **kwargs):
        from mpl_toolkits.basemap import Basemap
        import matplotlib.pyplot as plt
        # lon_0, lat_0 are the center point of the projection.
        # resolution = 'l' means use low resolution coastlines.
        if bigmap:
            m = Basemap(projection='hammer', lon_0=lon, resolution='c', ax=ax)
        else:
            m = Basemap(projection='ortho', lon_0=lon, lat_0=lat, resolution='l', ax=ax)
        #m = Basemap(width=width,height=width,projection='aeqd',
        #    lat_0=lat,lon_0=lon, resolution='l', ax=ax)
        if draw_countries:
            m.drawcountries(linewidth=0.5)
        m.drawcoastlines()
        m.drawmapboundary(fill_color='white')
        #m.drawmapboundary()
        m.fillcontinents(color='#D3D3D3', lake_color='#D3D3D3', zorder=0)  # light gray
        # draw parallels and meridians.
        m.drawparallels(np.arange(-90., 120., 30.))
        m.drawmeridians(np.arange(0., 390., 30.))
        # , lat=0, lon=0, bigmap=False,circles=(30, 90), circles_around=None, lines=None,
        self.plot_(m, lat=lat, lon=lon, bigmap=bigmap, **kwargs)

        #plt.title('Full Disk Orthographic Projection')

        def on_press(event):
            global lat_press, lon_press
            lon_press, lat_press = m(event.xdata, event.ydata, 'inverse')
            print 'position press  lat: %.2f  lon: %.2f' % (lat_press, lon_press)

        def on_release(event):
            lon_release, lat_release = m(event.xdata, event.ydata, 'inverse')
            dist_km = gps2DistAzimuth(lat_press, lon_press, lat_release,
                                      lon_release)[0] / 1000.
            dist_degree = gps2DistDegree(lat_press, lon_press, lat_release,
                                         lon_release)
            if dist_km > 0.1:
                print 'position release lat: %.2f  lon: %.2f' % (lat_release, lon_release)
                print 'Distance between points: %.2f degree or %.2f km' % (dist_degree, dist_km)
        plt.connect('button_press_event', on_press)
        plt.connect('button_release_event', on_release)
        if show:
            plt.show()
开发者ID:iceseismic,项目名称:sito,代码行数:43,代码来源:events.py


示例16: __init__

    def __init__(self, img):
      imshape = img.shape
      self.figure = P.imshow(img, extent=(0,imshape[1],imshape[0],0))
      P.title('Removal of radial distortion')
      P.xlabel('Select sets of three points with left mouse button,\nclick right button to process.')
      
      P.connect('button_press_event', self.button_press)
      P.connect('motion_notify_event', self.mouse_move)

      self.img = N.atleast_3d(img)
      self.points = []
      self.centre = ((N.array(self.img.shape)-1)/2.)[:2][::-1]
      self.height = imshape[0]
      self.width = imshape[1]
      
      self.make_cursorline()
      self.figure.axes.set_autoscale_on(False)

      P.show()
      P.close()
开发者ID:5n1p,项目名称:python-seminar,代码行数:20,代码来源:radial.py


示例17: main

def main(): 

    # setup the command line parser options 
    parser = argparse.ArgumentParser(description='')
    parser.add_argument('filenames', help='Training output files', nargs='+')

    args = parser.parse_args()
    filenames = args.filenames
    pl.connect('key_press_event',kevent.press)

    ddata = {}
    for filename in filenames:
        rdata    = np.loadtxt(filename) 
        if len(rdata.shape)> 1: pindex = (-1,0)
        else:                   pindex = (0)
        
        #(nr, nc) = rdata.shape 

        fparams = ssexyhelp.getReduceParamMap(filename)
        (alpha, Ns, beta, delta) = (fparams['alpha'], fparams['N'] , fparams['b'], fparams['delta'])
        seed = int(findKbV(fparams, ''))
        if not(delta in ddata.keys()): ddata[delta] = np.zeros(30) 
        else:                          ddata[delta][seed] = rdata[pindex]

    fig = pl.figure(1, figsize=(13,6))
    ax  = pl.subplot(111)
    colors = ["#66CAAE", "#CF6BDD", "#E27844", "#7ACF57", "#92A1D6", "#E17597", "#C1B546",'b']

    i = 0
    for delta, data in ddata.iteritems():
        ax.plot(range(len(data)), data,  
                color=colors[i], lw=3, ls='-',
                label = r'$\Delta = %0.2f$' %delta)
        i += 1

    pl.xlabel('Instance')
    pl.ylabel('LL')
    pl.legend(loc = 'best')
    pl.title(r'$\beta=%0.2f \, \alpha=%0.2f $' %(beta, alpha), fontsize = 20)
    pl.tight_layout()
    pl.show()
开发者ID:BohdanKul,项目名称:Scripts,代码行数:41,代码来源:visual.py


示例18: three_point_test

def three_point_test():
	import collections

	points = collections.deque(maxlen=3)
	def add_point(event):
		x, y = event.xdata, event.ydata
		points.append((x, y))
		pylab.cla()
		pylab.scatter(*zip(*points))
		pylab.xlim(-10, 10)
		pylab.ylim(-10, 10)

		pylab.draw()
		if len(points) < 3: return

		c, r = three_point_circle(*points)
		cir = pylab.Circle(c, r)
		pylab.gca().add_patch(cir)

		for p in points:
			angle = angle_at_point(c, p)
			if angle < 0:
				angle += 2*np.pi
			if angle >= np.pi:
				angle = angle - np.pi
			print np.degrees(angle)
			dx, dy = np.array((np.cos(angle), np.sin(angle)))
			pylab.text(p[0], p[1], "%.2f"%np.degrees(angle))
			pylab.arrow(p[0], p[1], dx, dy)
		pylab.show()
		
	
	#pylab.scatter(*zip(a, b, c))
	#c, r = three_point_circle(a, b, c)
	#print c, r
	pylab.xlim(-10, 10)
	pylab.ylim(-10, 10)

	pylab.connect('button_release_event', add_point)
	pylab.show()
开发者ID:tru-uof,项目名称:okn-yaw-analysis,代码行数:40,代码来源:curvemodel.py


示例19: display

def display(data=None, orient='LPS', overlay=None, colormap=cm.gray, pixdim=None):
    "mri=img.decimate(nim, 5)"
    "ex. slice.plot(mri)"

    import sys
    print sys.argv
    if data == None:
        try:
            fn=sys.argv[1]
            from mri import img
            data = img.read(fn)
        except AttributeError:
            print 'not passing data arg'
            print('lets plot random data')
            from numpy import random
            data = random.randn(10,10,10)

    try:
        data.qform
        print 'think its a nifti volume'
        nim = data
        mrdata = nim.data
        print shape(mrdata)
        pixdim = nim.voxdim[::-1]

    except AttributeError:
        if pixdim != None:
            print 'using user supplied pixeldimensions', pixdim
        else:
            print 'probably not a nifti volume. using voxel units instead of actual distance units'
            pixdim = [1.0,1.0,1.0]; #unitless
        mrdata = data

    fig = figure()
    subplots_adjust(left=.15, bottom=.15,right=1, top=.95,wspace=.25, hspace=.35)

    ax1 = fig.add_subplot(221);#axis('off')
    #colorbar(fig,ax=ax1)
    xlabel('Anterior (A->P 1st Dim)');ylabel('Right (R->L 2nd Dim)')
    ax2 = fig.add_subplot(222);#axis('off')
    xlabel('Inferior (I->S Dim)');ylabel('Anterior (A->P 1st Dim)')
    ax3 = fig.add_subplot(223);#axis('off')
    xlabel('Infererior (I->S 3rd dim)');ylabel('Right (R->L 2nd Dim)')
    coord = fig.add_subplot(224);axis('off')
    tracker = IndexTracker(mrdata, ax1, ax2, ax3, colormap, pixdim, overlay, coord)
    fig.canvas.mpl_connect('scroll_event', tracker.onscroll)
    cid = connect('button_press_event', tracker.click)

    show()


    return tracker
开发者ID:badbytes,项目名称:pymeg,代码行数:52,代码来源:viewmri.py


示例20: Initialize

	def Initialize(self):
		"""
		Load and display bitmap figure, and start data collection process.
		"""
		#Load and show data plot
		im = imread(self.ImageFile)
		imshow(flipud(im), origin="lower")
		self.EventId = connect("button_press_event", self.GetPosition)

		#Get toolbar handle
		self.ToolBar = get_current_fig_manager().toolbar

		print "First click on (x_min, y_min), then (x_min, y_max) and finally (x_max, y_min). This is used for calibration. Then click on all the datapoints. Right click when finished."
开发者ID:nepstad,项目名称:scriptz,代码行数:13,代码来源:datapointextractor.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pylab.contour函数代码示例发布时间:2022-05-25
下一篇:
Python pylab.concatenate函数代码示例发布时间: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