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


Python pylab.sca函数代码示例

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


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

示例1: plot_time_course

 def plot_time_course(self, data, mode='boolean', fontsize=16):
     # TODO sort columnsi alphabetically
     # FIXME: twiny labels are slightly shifted
     # TODO flip 
     if mode == 'boolean':
         cm = pylab.get_cmap('gray')
         pylab.clf() 
         data = pd.DataFrame(data).fillna(0.5)
         pylab.pcolor(data, cmap=cm, vmin=0, vmax=1, 
             shading='faceted')
         pylab.colorbar()
         ax1 = pylab.gca()
         ax1.set_xticks([])
         Ndata = len(data.columns)
         ax1.set_xlim(0, Ndata)
         ax = pylab.twiny()
         ax.set_xticks(pylab.linspace(0.5, Ndata+0.5, Ndata ))
         ax.set_xticklabels(data.columns, fontsize=fontsize, rotation=90)
         times = list(data.index)
         Ntimes = len(times)
         ax1.set_yticks([x+0.5 for x in times])
         ax1.set_yticklabels(times[::-1],  
                 fontsize=fontsize)
         pylab.sca(ax1)
     else:
         print('not implemented')
开发者ID:cellnopt,项目名称:cellnopt,代码行数:26,代码来源:simulator.py

示例2: add_subplot_name

def add_subplot_name(offsets,subplot_names="abcdefghijklmnopq"):
    if len(offsets) != 2:
        raise Exception("Offsets for x and y coordinates should be provided")
    for iax,ax in enumerate(pylab.gcf().axes):
        pylab.sca(ax)
        pylab.text(offsets[0],1.+offsets[1],"({})".format(subplot_names[iax]),
                   transform=pylab.gca().transAxes)
开发者ID:kitchoi,项目名称:geodat,代码行数:7,代码来源:subplot.py

示例3: finish_trajectory_plot

 def finish_trajectory_plot(self,axes,t,filename):
 
     # Plot histograms! 0 is the upper panel, 1 the lower.
     plt.sca(axes[1])
     
     bins = np.linspace(np.log10(swap.pmin),np.log10(swap.pmax),32,endpoint=True)
     bins = 10.0**bins
     colors = ['blue','red','black']
     labels = ['Training: Sims','Training: Duds','Test: Survey']
     
     for j,kind in enumerate(['sim','dud','test']):
         
         self.collect_probabilities(kind)
         p = self.probabilities[kind]
         
         # Sometimes all probabilities are lower than pmin! 
         # Snap to grid.
         p[p<swap.pmin] = swap.pmin
         # print "kind,bins,p = ",kind,bins,p
         
         # Pylab histogram:
         plt.hist(p, bins=bins, histtype='stepfilled', color=colors[j], alpha=0.7, label=labels[j])
         plt.legend(prop={'size':10})
     
     # Add timestamp in top righthand corner:
     plt.sca(axes[0])
     plt.text(1.3*swap.prior,0.27,t,color='gray')
     
     # Write out to file:
     plt.savefig(filename,dpi=300)
         
     return
开发者ID:charlottenosam,项目名称:SpaceWarps,代码行数:32,代码来源:collection.py

示例4: PSFrange

    def PSFrange(self,junkAx):
        """
        Display function that you shouldn't call directly.
        """

        #ca=pyl.gca()
        pyl.sca(self.sp1)

        print self.starsScat

        newLim=[self.sp1.get_xlim(),self.sp1.get_ylim()]
        self.psfPlotLimits=newLim[:]
        w=num.where((self.points[:,0]>=self.psfPlotLimits[0][0])&(self.points[:,0]<=self.psfPlotLimits[0][1])&(self.points[:,1]>=self.psfPlotLimits[1][0])&(self.points[:,1]<=self.psfPlotLimits[1][1]))[0]

        if self.starsScat<>None:
            self.starsScat.remove()
            self.starsScat=None

        for ii in range(len(self.showing)):
            if self.showing[ii]: self.moffPatchList[ii][0].remove()

        for ii in range(len(self.showing)):
            if ii not in w: self.showing[ii]=0
            else: self.showing[ii]=1



        for ii in range(len(self.showing)):
            if self.showing[ii]:
                self.moffPatchList[ii]=self.sp4.plot(self.moffr,self.moffs[ii])
        self.sp4.set_xlim(0,30)
        self.sp4.set_ylim(0,1.02)

        pyl.draw()
开发者ID:Mikea1985,项目名称:trippy,代码行数:34,代码来源:psfStarChooser.py

示例5: plot_ima_mass_matrix

def plot_ima_mass_matrix(start, finish, product=None, colorbar=True, ax=None, blocks=None, **kwargs):
    """ Integrate to produce a mass-matrix from start-finish, processing azimuths"""

    if (finish - start) < aspera_scan_time:
        raise ValueError("Duration too short: %d" % (finish - start))

    if not blocks:
        blocks = read_ima(start, finish, **kwargs)

    if ax is None:
        ax = plt.gca()

    plt.sca(ax)

    products_to_process = ("CO2", "H", "O", "Hsp", "alpha", "O2", "He")
    if product:
        if not hasattr(product, "__iter__"):
            products_to_process = [product]
        else:
            products_to_process = product

    img = np.zeros_like(blocks[0]["sumions"])

    for b in blocks:
        inx, = np.where((b["tmptime"] > start) & (b["tmptime"] < finish))
        if inx.shape[0]:
            for p in products_to_process:
                img += np.sum(b[p][:, :, inx], 2)

    plt.imshow(img, origin="lower")
    if colorbar:
        plt.colorbar(cax=celsius.make_colorbar_cax())

    return img
开发者ID:irbdavid,项目名称:mex,代码行数:34,代码来源:aspera_hn.py

示例6: plot

    def plot(self, color_line='r', bgcolor='grey', color='yellow', lw=4, 
            hold=False, ax=None):

        xmax = self.xmax + 1
        if ax:
            pylab.sca(ax)
        pylab.fill_between([0,xmax], [0,0], [20,20], color='red', alpha=0.3)
        pylab.fill_between([0,xmax], [20,20], [30,30], color='orange', alpha=0.3)
        pylab.fill_between([0,xmax], [30,30], [41,41], color='green', alpha=0.3)

        if self.X is None:
            X = range(1, self.xmax + 1)

        pylab.fill_between(X, 
            self.df.mean()+self.df.std(), 
            self.df.mean()-self.df.std(), 
            color=color, interpolate=False)

        pylab.plot(X, self.df.mean(), color=color_line, lw=lw)
        pylab.ylim([0, 41])
        pylab.xlim([0, self.xmax+1])
        pylab.title("Quality scores across all bases")
        pylab.xlabel("Position in read (bp)")
        pylab.ylabel("Quality")
        pylab.grid(axis='x')
开发者ID:biokit,项目名称:biokit,代码行数:25,代码来源:boxplot.py

示例7: setupplot

def setupplot(secondax=False, **kwargs):
    ytickv = np.linspace(YR[0],YR[1],6)
    yticknames = map('{:0.0f}'.format, ytickv)
    tmp = dict(
        ylabel='Temperature [c]',
        yr=minmax(ytickv), ytickv=ytickv,
        yticknames=yticknames,
    )
    tmp.update(kwargs)
    ax = setup(**tmp)
    
    if secondax:
        subplt = kwargs.get('subplt',None)
        f = lambda x: '{:0.0f}'.format(1.8*x + 32.0)
        yticknames = map(f, ytickv)
        ax2 = ax.twinx()
        ax2.set_ylabel(r"Temperature [F]")
        ax2.set_ylim(minmax(ytickv))
        ax2.yaxis.set_major_locator(matplotlib.ticker.FixedLocator(ytickv))
        ax2.yaxis.set_major_formatter(matplotlib.ticker.FixedFormatter(yticknames))
        pylab.sca(ax)
        
        # setup(ax=ax.twinx(),
        #       subplt=subplt,
        #       ylabel='Temperature [F]',
        #       yr=minmax(ytickv), ytickv=ytickv, yticknames=yticknames)
        
    
    return ax
开发者ID:ajmendez,项目名称:templog,代码行数:29,代码来源:plot_temperature.py

示例8: render

    def render(self, axes, plot_nodes=False):
        plt.sca(axes)
        for idx, nodeID in enumerate(self._osm.ways.keys()):
            wayTags = self._osm.ways[nodeID].tags
            wayType = None
            if 'highway' in wayTags.keys():
                wayType = wayTags['highway']

            if wayType in [
                           'primary',
                           'primary_link',
                           'unclassified',
                           'secondary',
                           'secondary_link',
                           'tertiary',
                           'tertiary_link',
                           'residential',
                           'trunk',
                           'trunk_link',
                           'motorway',
                           'motorway_link'
                            ]:
                oldX = None
                oldY = None

                if wayType in list(MatplotLibMap.renderingRules.keys()):
                    thisRendering = MatplotLibMap.renderingRules[wayType]
                else:
                    thisRendering = MatplotLibMap.renderingRules['default']

                for nCnt, nID in enumerate(self._osm.ways[nodeID].nds):
                    y = float(self._osm.nodes[nID].lat)
                    x = float(self._osm.nodes[nID].lon)

                    self._node_map[(x, y)] = nID

                    if oldX is None:
                        pass
                    else:
                        plt.plot([oldX,x],[oldY,y],
                                marker          = '',
                                linestyle       = thisRendering['linestyle'],
                                linewidth       = thisRendering['linewidth'],
                                color           = thisRendering['color'],
                                solid_capstyle  = 'round',
                                solid_joinstyle = 'round',
                                zorder          = thisRendering['zorder'],
                                picker=2
                        )

                        if plot_nodes == True and (nCnt == 0 or nCnt == len(self._osm.ways[nodeID].nds) - 1):
                            plt.plot(x, y,'ro', zorder=5)

                    oldX = x
                    oldY = y

        self._fig.canvas.mpl_connect('pick_event', self.__onclick__)
        plt.draw()
开发者ID:ssarangi,项目名称:osmpy,代码行数:58,代码来源:osm_to_networkx.py

示例9: plotsim

    def plotsim(self, experiments=None, fontsize=16, vmin=0, vmax=1, cmap='gray'):
        """

        :param experiments: if None, shows the steady state for each experiment and species
            if provided, must be a valid experiment name (see midas.experiments attribute)
            in which case, for that particular experiment, the steady state and all previous
            states are shown for each species.


        A simulation must be performed using :meth:`simulate`
        ::

            # those 2 calls are identical
            s.plotsim(experiments=8)
            s.plotsim(experiments=8)
            # This plot the steady states for all experiments
            s.plotsim()

        """
        # This is for all experiments is experiments is None
        cm = pylab.get_cmap(cmap)
        pylab.clf()

        if experiments is None: # takes the latest (steady state) of each experiments
            data = pd.DataFrame(self.debug_values[-1]).fillna(0.5)
        else:
            exp_name = self.midas.experiments.ix[experiments].name
            index_exp = list(self.midas.experiments.index).index(exp_name)

            data = [(k, [self.debug_values[i][k][index_exp] for i in range(0, len(self.debug_values))])
                    for k in self.debug_values[0].keys()]
            data = dict(data)
            data = pd.DataFrame(data).fillna(0.5)
            data = data.ix[data.index[::-1]]
        self.dummy = data

        pylab.pcolor(data, cmap=cm, vmin=vmin, vmax=vmax,
                shading='faceted', edgecolors='gray')
        pylab.colorbar()
        ax1 = pylab.gca()
        ax1.set_xticks([])
        Ndata = len(data.columns)
        ax1.set_xlim(0, Ndata)
        ax1.set_ylim(0, len(data))
        ax = pylab.twiny()

        # FIXME seems shifted. could not fix it xticklabels seems to reset the position of the ticks
        xr = pylab.linspace(0.5, Ndata-1.5, Ndata)
        ax.set_xticks(xr)
        ax.set_xticklabels(data.columns, fontsize=fontsize, rotation=90)
        times = list(data.index)
        Ntimes = len(times)
        ax1.set_yticks([x+0.5 for x in times])
        ax1.set_yticklabels(times[::-1],
                    fontsize=fontsize)
        pylab.sca(ax1)
        #pylab.title("Steady state for all experiments(x-axis)\n\n\n\n")
        pylab.tight_layout()
开发者ID:cellnopt,项目名称:cellnopt,代码行数:58,代码来源:steady.py

示例10: decorator

 def decorator(ax=None):
     ax1 = ax if ax else gca()
     ax2 = ax1.twiny()
     ax2.set_ylim(y for y in ax1.get_ylim())
     ax2.set_xlim(func(x) for x in ax1.get_xlim())
     if not ax:
         sca(ax1)
         draw()
     return ax2
开发者ID:baldwint,项目名称:wanglib,代码行数:9,代码来源:misc.py

示例11: plot_mex_orbits_bar

def plot_mex_orbits_bar(start=None, finish=None, ax=None, height=0.02, number_every=10, sharex=False, labels=True):
    """docstring for plot_mex_orbits_bar"""

    fig = plt.gcf()
    if ax is None:
        ax = plt.gca()

    xlims = plt.xlim()

    p = ax.get_position()
    if sharex:
        if isinstance(sharex, bool):
            sharex = ax
    else:
        sharex = None
    new_ax = fig.add_axes([p.x0, p.y1, p.x1 - p.x0, height], sharex=sharex)

    if start is None:
        start = xlims[0]
    if finish is None:
        finish = xlims[1]

    plt.xlim(start, finish)
    plt.ylim(0., 1.)

    x = np.array([1., 0., 0., 1., 1.])
    y = np.array([1., 1., 0., 0., 1.])

    orbit_count = 0
    orbit_list = list(mex.orbits.values())
    for o in orbit_list:
        if o.number % 2 == 0:
            continue
        if (o.start < finish) & (o.finish > start):
            dx = o.finish - o.start
            plt.fill(x * dx + o.start, y, 'k', edgecolor='none')
            orbit_count = orbit_count + 1

    if number_every is None:
        number_every = int(orbit_count / 10)

    if number_every:
        numbered_orbits = [o for o in orbit_list if (o.number % number_every) == 0]

    ticks = [o.periapsis for o in numbered_orbits]
    nums  = [o.number for o in numbered_orbits]
    new_ax.yaxis.set_major_locator(mpl.ticker.NullLocator())

    new_ax.xaxis.set_major_locator(mpl.ticker.FixedLocator(ticks))
    new_ax.xaxis.set_major_formatter(mpl.ticker.FixedFormatter(nums))
    # new_ax.xaxis.set_major_locator(mpl.ticker.MaxNLocator(nbins=5, steps=[1,2,5,10]))
    new_ax.tick_params(axis='x', direction='out', bottom=False, top=True, labelbottom=False, labeltop=True)
    if labels:
        plt.ylabel("MEX", rotation='horizontal')

    plt.sca(ax)
    return new_ax
开发者ID:irbdavid,项目名称:mex,代码行数:57,代码来源:mex_sc.py

示例12: __onclick__

    def __onclick__(self, event):
        threshold = 0.001
        print("Clicked mouse")

        if self._node1 is not None and self._node2 is not None:
            return None

        if isinstance(event.artist, Line2D):
            thisline = event.artist
            xdata = thisline.get_xdata()
            ydata = thisline.get_ydata()
            ind = event.ind
            point = (float(np.take(xdata, ind)[0]), float(np.take(ydata, ind)[0]))
            node_id = self._node_map[point]

            if self._node1 is None:
                self._node1 = Node(node_id, point[0], point[1])
                self._mouse_click1 = (event.mouseevent.xdata, event.mouseevent.ydata)

                for axes in self._main_rendering_axes:
                    plt.sca(axes)
                    plt.plot(self._mouse_click1[0], self._mouse_click1[1], 'ro', zorder=100)

                plt.draw()
                return self._node1
            else:
                # Do not allow clicking of node id's within 100 node distances
                if abs(point[0] - self._node1.lon) < threshold and abs(point[1] - self._node1.lat) < threshold:
                    return None

                self._node2 = Node(node_id, point[0], point[1])
                self._mouse_click2 = (event.mouseevent.xdata, event.mouseevent.ydata)
                print("Both points marked")

                for axes in self._main_rendering_axes:
                    plt.sca(axes)
                    plt.plot(self._mouse_click2[0], self._mouse_click2[1], 'ro', zorder=100)

                plt.draw()

                # Now both the points have been marked. Now try to find a path.
                path_dijkstra, paths_considered_dijkstra = shortest_path.dijkstra(self._graph, self._node1.id, self._node2.id)
                path_astar, paths_considered_astar = shortest_path.astar(self._graph, self._node1.id, self._node2.id, self._osm)
                path_bidirectional_dijkstra, paths_considered_from_start_bidirectional_dijkstra, paths_considered_from_end_bidirectional_dijkstra = shortest_path.bidirectional_dijkstra(self._graph, self._node1.id, self._node2.id)

                self.plot_path(self._get_axes('dijkstra', 'main'), path_dijkstra, MatplotLibMap.renderingRules['correct_path'], animate=False)
                self.plot_considered_paths(self._get_axes('dijkstra', 'paths_considered'), path_dijkstra, (paths_considered_dijkstra, 'green'))

                self.plot_path(self._get_axes('astar', 'main'), path_astar, MatplotLibMap.renderingRules['correct_path'], animate=False)
                self.plot_considered_paths(self._get_axes('astar', 'paths_considered'), path_astar, (paths_considered_astar, 'green'))

                self.plot_path(self._get_axes('bidirectional_dijkstra', 'main'), path_bidirectional_dijkstra, MatplotLibMap.renderingRules['correct_path'], animate=False)
                self.plot_considered_paths(self._get_axes('bidirectional_dijkstra', 'paths_considered'), path_bidirectional_dijkstra, (paths_considered_from_start_bidirectional_dijkstra, 'green'), (paths_considered_from_end_bidirectional_dijkstra, 'red'))

                plt.savefig("shortest_path.png")
                return self._node2
开发者ID:ssarangi,项目名称:osmpy,代码行数:56,代码来源:osm_to_networkx.py

示例13: finish_history_plot

    def finish_history_plot(self,axes,t,filename):

        plt.sca(axes)

        # Timestamp:
        plt.text(100,swap.Imax+0.02,t,color='gray')

        plt.savefig(filename,dpi=300)

        return
开发者ID:willettk,项目名称:SpaceWarps,代码行数:10,代码来源:bureau.py

示例14: plot_history

    def plot_history(self,axes):

        plt.sca(axes)
        I = self.traininghistory['Skill']
        N = np.linspace(1, len(I), len(I), endpoint=True)

        # Information contributions:
        plt.plot(N, I, color="green", alpha=0.2, linewidth=2.0, linestyle="-")
        plt.scatter(N[-1], I[-1], color="green", alpha=0.5)

        return
开发者ID:rgavazzi,项目名称:SpaceWarps,代码行数:11,代码来源:agent.py

示例15: plot_considered_paths

    def plot_considered_paths(self, axes, path, *paths_considered_tuples):
        plt.sca(axes)
        edges = zip(path, path[1:])

        # Render all the paths considered
        for path_considered_tuple in paths_considered_tuples:
            paths_considered = path_considered_tuple[0]
            color = path_considered_tuple[1]
            for i, edge in enumerate(paths_considered):
                node_from = self._osm.nodes[edge[0]]
                node_to = self._osm.nodes[edge[1]]
                x_from = node_from.lon
                y_from = node_from.lat
                x_to = node_to.lon
                y_to = node_to.lat

                plt.plot([x_from,x_to],[y_from,y_to],
                        marker          = '',
                        linestyle       = '-',
                        linewidth       = 1,
                        color           = color,
                        solid_capstyle  = 'round',
                        solid_joinstyle = 'round',
                        zorder          = 0,
                        )

        # Render all the paths considered
        for i, edge in enumerate(edges):
            node_from = self._osm.nodes[edge[0]]
            node_to = self._osm.nodes[edge[1]]
            x_from = node_from.lon
            y_from = node_from.lat
            x_to = node_to.lon
            y_to = node_to.lat

            # if i == 0:
            #     x_from = self._mouse_click1[0]
            #     y_from = self._mouse_click1[1]
            #
            # if i == len(path) - 2:
            #     x_to = self._mouse_click2[0]
            #     y_to = self._mouse_click2[1]

            plt.plot([x_from,x_to],[y_from,y_to],
                    marker          = '',
                    linestyle       = '-',
                    linewidth       = 3,
                    color           = 'black',
                    solid_capstyle  = 'round',
                    solid_joinstyle = 'round',
                    zorder          = 1,
                    )

        plt.draw()
开发者ID:ssarangi,项目名称:osmpy,代码行数:54,代码来源:osm_to_networkx.py


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