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

Python axes.Axes类代码示例

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

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



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

示例1: add_collection3d

    def add_collection3d(self, col, zs=0, zdir='z'):
        '''
        Add a 3d collection object to the plot.

        2D collection types are converted to a 3D version by
        modifying the object and adding z coordinate information.

        Supported are:
            - PolyCollection
            - LineColleciton
            - PatchCollection
        '''
        zvals = np.atleast_1d(zs)
        if len(zvals) > 0 :
            zsortval = min(zvals)
        else :
            zsortval = 0   # FIXME: Fairly arbitrary. Is there a better value?

        if type(col) is collections.PolyCollection:
            art3d.poly_collection_2d_to_3d(col, zs=zs, zdir=zdir)
            col.set_sort_zpos(zsortval)
        elif type(col) is collections.LineCollection:
            art3d.line_collection_2d_to_3d(col, zs=zs, zdir=zdir)
            col.set_sort_zpos(zsortval)
        elif type(col) is collections.PatchCollection:
            art3d.patch_collection_2d_to_3d(col, zs=zs, zdir=zdir)
            col.set_sort_zpos(zsortval)

        Axes.add_collection(self, col)
开发者ID:dhomeier,项目名称:matplotlib-py3,代码行数:29,代码来源:axes3d.py


示例2: draw

    def draw(self, renderer):

        if self._parent is not None:
            self.axes.viewLim.set(self._parent.viewLim)
            self.set_position(self._parent.get_position())

        Axes.draw(self, renderer)
开发者ID:aplpy,项目名称:aplpy-experimental,代码行数:7,代码来源:axes.py


示例3: TelescopeEventView

class TelescopeEventView(tk.Frame, object):
    """ A frame showing the camera view of a single telescope """

    def __init__(self, root, telescope, data=None, *args, **kwargs):
        self.telescope = telescope
        super(TelescopeEventView, self).__init__(root)
        self.figure = Figure(figsize=(5, 5), facecolor='none')
        self.ax = Axes(self.figure, [0, 0, 1, 1], aspect=1)
        self.ax.set_axis_off()
        self.figure.add_axes(self.ax)
        self.camera_plot = CameraPlot(telescope, self.ax, data, *args, **kwargs)
        self.canvas = FigureCanvasTkAgg(self.figure, master=self)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        self.canvas._tkcanvas.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
        self.canvas._tkcanvas.config(highlightthickness=0)

    @property
    def data(self):
        return self.camera_plot.data

    @data.setter
    def data(self, value):
        self.camera_plot.data = value
        self.canvas.draw()
开发者ID:MaxNoe,项目名称:cta_event_viewer,代码行数:25,代码来源:__init__.py


示例4: _set_lim_and_transforms

    def _set_lim_and_transforms(self):
        """
        This is called once when the plot is created to set up all the
        transforms for the data, text and grids.
        """
        rot = 30

        # Get the standard transform setup from the Axes base class
        Axes._set_lim_and_transforms(self)

        # Need to put the skew in the middle, after the scale and limits,
        # but before the transAxes. This way, the skew is done in Axes
        # coordinates thus performing the transform around the proper origin
        # We keep the pre-transAxes transform around for other users, like the
        # spines for finding bounds
        self.transDataToAxes = self.transScale + \
            self.transLimits + transforms.Affine2D().skew_deg(rot, 0)

        # Create the full transform from Data to Pixels
        self.transData = self.transDataToAxes + self.transAxes

        # Blended transforms like this need to have the skewing applied using
        # both axes, in axes coords like before.
        self._xaxis_transform = (transforms.blended_transform_factory(
            self.transScale + self.transLimits,
            transforms.IdentityTransform()) +
            transforms.Affine2D().skew_deg(rot, 0)) + self.transAxes
开发者ID:DanHickstein,项目名称:matplotlib,代码行数:27,代码来源:skewt.py


示例5: center_histogram_2d

def center_histogram_2d(par1, par2):
    fig22 = figure(22)
    ax22 = Axes(fig22, [.1, .1, .8, .8])
    fig22.add_axes(ax22)
    div = 10.
    ll1 = l_dict[par1]
    ll2 = l_dict[par2]
    ss1 = ss_dict[par1]
    ss2 = ss_dict[par2]
    H, xedges, yedges = histogram2d(ss1[0], ss2[0], bins = [linspace(-ll1 / 2., ll1 / 2., div + 1) , linspace(-ll2 / 2., ll2 / 2., div * ll1 / ll2 + 1)], normed = 0)

    #extent = [-ll1 / 2., ll1 / 2., -ll2 / 2., ll2 / 2.]#[xedges[0], xedges[-1], yedges[0], yedges[-1]]
    #im = imshow( H, extent=extent )#'binary', cmap='jet' 
    #im.set_interpolation( 'bilinear' )
    #colorbar()
    ax22 = Axes3D(fig22, [.1, .1, .8, .8])
    x = (xedges[range(0, len(xedges) - 1)] + xedges[range(1, len(xedges))]) / 2.
    y = (yedges[range(0, len(yedges) - 1)] + yedges[range(1, len(yedges))]) / 2.
    #ax10.scatter3D( xedges.ravel(), yedges.ravel(), H.ravel() )
    xx = outer(x, ones(len(y)))
    yy = outer(ones(len(x)), y)
    ax22.plot_wireframe(xx, yy, H)#, rstride=1, cstride=1 

    #H, xedges, yedges = histogram2d( ss1[0], ss2[0], bins=[div, div], normed=0 )
    #ax22.set_xticks( arange( -ll1 / 2., ll1 / 2., ll1 / 10. ) )
    #ax22.set_title( 'histogram of fibers centroid in 2D -- sim' )
    #ax22 = Axes3D( fig22 )
    #X, Y, Z = xedges, yedges, H
    #ax22.plot3D( X.ravel(), Y.ravel(), Z.ravel(), 'ro' )  
    #ax22.contour3D( X[:-1], Y[:-1], Z )
    #ax22.plot_wireframe( X, Y, Z, rstride=6, cstride=6, color='blue', linewidth=0.5 )
    #ax22.plot_surface( X[:-1], Y[:-1], Z )
    draw()
    return 0
开发者ID:kelidas,项目名称:scratch,代码行数:34,代码来源:specimen3D_fibers.py


示例6: plot_metrics_evolution

    def plot_metrics_evolution(cls, ax: axes.Axes, y, x=None, **plot_config):

        # default config
        config = defaultdict(lambda: None)
        config['xlabel'] = 'time'
        for key, value in plot_config.items():
            config[key] = value


        # major ticks every 50
        # major_ticks = np.arange(0, 900, 50)
        # ax.set_xticks(major_ticks)

        # plotting the graph
        if x is None:
            x = np.arange(len(y))

        # check if element of x is tuple or just number
        lines = []
        if isinstance(y[0], (list, tuple)):
            for y_i in zip(*y):
                line, = ax.plot(x, y_i)
                lines.append(line)
        else:
            line, = ax.plot(x, y)
            # colour
            if config['colour'] is not None:
                line.set_color(config['colour'])
            lines.append(line)


        cls.apply_plot_config(ax, config)

        return lines
开发者ID:rbgorbet,项目名称:Hylozoic-Series-3,代码行数:34,代码来源:data_plotter.py


示例7: set_top_view

 def set_top_view(self):
     xdwl = (0.95/self.dist)
     xdw = (0.9/self.dist)
     ydwl = (0.95/self.dist)
     ydw = (0.9/self.dist)
     Axes.set_xlim(self, -xdwl, xdw)
     Axes.set_ylim(self, -ydwl, ydw)
开发者ID:,项目名称:,代码行数:7,代码来源:


示例8: cla

    def cla(self):
        """
        Override to set up some reasonable defaults.
        """
        # Don't forget to call the base class
        Axes.cla(self)

        # Turn off minor ticking altogether
        self.xaxis.set_minor_locator(NullLocator())
        self.yaxis.set_minor_locator(NullLocator())

        self.xaxis.set_major_locator(MaxNLocator(5, prune='both'))
        self.yaxis.set_major_locator(MaxNLocator(5, prune='both'))

        # Do not display ticks -- we only want gridlines and text
        self.xaxis.set_ticks_position('none')
        self.yaxis.set_ticks_position('none')

        self.set_center(None, None)

        # FIXME: probabaly want to override autoscale_view
        # to properly handle wrapping introduced by margin
        # and properlty wrap data. 
        # It doesn't make sense to have xwidth > 360. 
        self._tight = True
开发者ID:rainwoodman,项目名称:skymapper,代码行数:25,代码来源:aea_projection.py


示例9: draw

    def draw(self, renderer):
        # draw the background patch
        self.axesPatch.draw(renderer)
        self._frameon = False

        # add the projection matrix to the renderer
        self.M = self.get_proj()
        renderer.M = self.M
        renderer.vvec = self.vvec
        renderer.eye = self.eye
        renderer.get_axis_position = self.get_axis_position

        # Calculate projection of collections and zorder them
        zlist = [(col.do_3d_projection(renderer), col) for col in self.collections]
        zlist.sort()
        zlist.reverse()
        for i, (z, col) in enumerate(zlist):
            col.zorder = i

        # Calculate projection of patches and zorder them
        zlist = [(patch.do_3d_projection(renderer), patch) for patch in self.patches]
        zlist.sort()
        zlist.reverse()
        for i, (z, patch) in enumerate(zlist):
            patch.zorder = i

        axes = (self.w_xaxis, self.w_yaxis, self.w_zaxis)
        for ax in axes:
            ax.draw_pane(renderer)
        for ax in axes:
            ax.draw(renderer)

        Axes.draw(self, renderer)
开发者ID:ranjithtenz,项目名称:cis530,代码行数:33,代码来源:axes3d.py


示例10: cla

    def cla(self):
        """Provide reasonable defaults for the axes.
        """
        # Call the base class.
        Axes.cla(self)
        self.grid(True)

        # Only the x-axis is shown, but there are 3 axes once all of the
        # projections are included.
        self.yaxis.set_visible(False)

        # Adjust the number of ticks shown.
        #self.set_xticks(np.linspace(0, self.viewLim.x1, 5))
        self.set_xticks(np.linspace(0, self.total, 5))

        # Turn off minor ticking altogether.
        self.xaxis.set_minor_locator(NullLocator())

        # Place the title a little higher than normal.
        self.title.set_y(1.02)

        # Modify the padding between the tick labels and the axis labels.
        self.xaxis.labelpad = 10 # In display units

        # Spacing from the vertices (tips) to the tip labels (in data coords, as
        # a fraction of self.total)
        self.tipoffset = 0.14
开发者ID:kdavies4,项目名称:matplotlib,代码行数:27,代码来源:ternary.py


示例11: __init__

    def __init__(self, fig, rect=None, *args, **kwargs):
        if rect is None:
            rect = [0.0, 0.0, 1.0, 1.0]
        self.fig = fig
        self.cids = []

        azim = kwargs.pop("azim", -60)
        elev = kwargs.pop("elev", 30)

        self.xy_viewLim = unit_bbox()
        self.zz_viewLim = unit_bbox()
        self.xy_dataLim = unit_bbox()
        self.zz_dataLim = unit_bbox()
        # inihibit autoscale_view until the axises are defined
        # they can't be defined until Axes.__init__ has been called
        self.view_init(elev, azim)
        self._ready = 0
        Axes.__init__(self, self.fig, rect, frameon=True, xticks=[], yticks=[], *args, **kwargs)

        self.M = None

        self._ready = 1
        self.mouse_init()
        self.create_axes()
        self.set_top_view()

        self.axesPatch.set_linewidth(0)
        self.fig.add_axes(self)
开发者ID:,项目名称:,代码行数:28,代码来源:


示例12: cla

 def cla(self):
     # Disconnect the various events we set.
     for cid in self.cids:
         self.figure.canvas.mpl_disconnect(cid)
     self.cids = []
     Axes.cla(self)
     self.grid(rcParams['axes3d.grid'])
开发者ID:,项目名称:,代码行数:7,代码来源:


示例13: draw

    def draw(self, renderer):
        # draw the background patch
        self.axesPatch.draw(renderer)
        self._frameon = False

        # add the projection matrix to the renderer
        self.M = self.get_proj()
        renderer.M = self.M
        renderer.vvec = self.vvec
        renderer.eye = self.eye
        renderer.get_axis_position = self.get_axis_position

        # Calculate projection of collections and zorder them
        zlist = [(col.do_3d_projection(renderer), col) \
                for col in self.collections]
        zlist.sort(reverse=True)
        for i, (z, col) in enumerate(zlist):
            col.zorder = getattr(col, '_force_zorder', i)


        # Calculate projection of patches and zorder them
        zlist = [(patch.do_3d_projection(renderer), patch) \
                for patch in self.patches]
        zlist.sort(reverse=True)
        for i, (z, patch) in enumerate(zlist):
            patch.zorder = i

        self.w_xaxis.draw(renderer)
        self.w_yaxis.draw(renderer)
        self.w_zaxis.draw(renderer)
        Axes.draw(self, renderer)
开发者ID:wxgeo,项目名称:geophar,代码行数:31,代码来源:__init__.py


示例14: plot_evolution

    def plot_evolution(cls, ax: axes.Axes, y, x=None, **plot_config):

        # default config
        config = defaultdict(lambda: None)
        config['xlabel'] = 'time'
        for key, value in plot_config.items():
            config[key] = value


        # plotting the graph
        if x is None:
            x = np.arange(len(y))

        # check if element of x is tuple or just number
        lines = []
        if isinstance(y[0], (list, tuple)):
            for y_i in zip(*y):
                line, = ax.plot(x, y_i)
                lines.append(line)
        else:
            line, = ax.plot(x, y)
            lines.append(line)

        cls.apply_plot_config(ax, config)
        plt.tight_layout()

        return lines
开发者ID:rbgorbet,项目名称:Hylozoic-Series-3,代码行数:27,代码来源:data_plotter.py


示例15: plot_mods

def plot_mods(ax: Axes, stats: Stats, most_popular_at_bottom=False, percentage=False):
    # FIXME different colors when using percentage with 10 mods
    mods_by_popularity = sorted(stats.players_by_mod.keys(),
                                key=lambda mod: stats.all_time_players_by_mod[mod], reverse=most_popular_at_bottom)
    labels = ["{} - avg. {:.2f} players".format(mod, stats.all_time_players_by_mod[mod] / len(stats.dates))
              for mod in mods_by_popularity]

    colors = ['red', 'green', 'blue', 'yellow', 'purple', 'lime', 'gray', 'cyan', 'orange', 'deeppink', 'black']
    colors = colors[0:len(mods_by_popularity)]
    colors = colors if most_popular_at_bottom else reversed(colors)
    ax.set_prop_cycle(color=colors)

    all_mods_values = np.row_stack([stats.players_by_mod[mod] for mod in mods_by_popularity])
    if percentage:
        with np.errstate(invalid='ignore'):
            all_mods_values = all_mods_values / all_mods_values.sum(axis=0) * 100
    ax.stackplot(stats.dates, all_mods_values, labels=labels, linewidth=0.1)

    if percentage:
        ax.set_ylim(bottom=0, top=100)
    else:
        ax.set_ylim(bottom=0)
    decorate_axes(ax)
    handles, labels = ax.get_legend_handles_labels()
    handles = handles if most_popular_at_bottom else reversed(handles)
    labels = labels if most_popular_at_bottom else reversed(labels)
    leg = ax.legend(handles, labels, loc='upper left', prop={'size': 10})
    leg.get_frame().set_alpha(0.5)
开发者ID:martin-t,项目名称:xon-activity-stats,代码行数:28,代码来源:qstat-parser.py


示例16: __init__

    def __init__(self, fig, rect=None, **kwargs):

        if rect == None:
            rect = [0.1,0.1,0.8,0.8]
        self.season = kwargs.pop('season',1)
        self.ra_direction = kwargs.pop('ra_direction',1)
        # center coordinate in (RA, Dec)
        self.center = get_kepler_center(season=self.season)
        # self.center must be set before Axes.__init__, because Axes.__init__
        # calls axes.cla(), which in turns calls set_ylim(), which is
        # overwritten in this class.

        self.ref_dec1, self.ref_dec2 = 20., 50.

        Axes.__init__(self, fig, rect, **kwargs)

        # prepare for the draw the ticks on the top & right axis
        self.twiny = self.twiny()
        self.twinx = self.twinx()

        #self.set_aspect(1.0)

        self.set_ra_ticks(5)
        self.set_dec_ticks(5)

        self.set_lim(self.center[0]-11, self.center[0]+11,
                     self.center[1]-9,  self.center[1]+9)
开发者ID:wangleon,项目名称:keplermap,代码行数:27,代码来源:keplermap.py


示例17: __init__

 def __init__(self, fig, rect, *args, **kwargs):
     self.aln = kwargs.pop("aln")
     nrows = len(self.aln)
     ncols = self.aln.get_alignment_length()
     self.alnidx = numpy.arange(ncols)
     self.app = kwargs.pop("app", None)
     self.showy = kwargs.pop('showy', True)
     Axes.__init__(self, fig, rect, *args, **kwargs)
     rgb = mpl_colors.colorConverter.to_rgb
     gray = rgb('gray')
     d = defaultdict(lambda:gray)
     d["A"] = rgb("red")
     d["a"] = rgb("red")
     d["C"] = rgb("blue")
     d["c"] = rgb("blue")
     d["G"] = rgb("green")
     d["g"] = rgb("green")
     d["T"] = rgb("yellow")
     d["t"] = rgb("yellow")
     self.cmap = d
     self.selector = RectangleSelector(
         self, self.select_rectangle, useblit=True
         )
     def f(e):
         if e.button != 1: return True
         else: return RectangleSelector.ignore(self.selector, e)
     self.selector.ignore = f
     self.selected_rectangle = Rectangle(
         [0,0],0,0, facecolor='white', edgecolor='cyan', alpha=0.3
         )
     self.add_patch(self.selected_rectangle)
     self.highlight_find_collection = None
开发者ID:ChriZiegler,项目名称:ivy,代码行数:32,代码来源:alignment.py


示例18: cla

 def cla(self):
     """
     Override to set up some reasonable defaults.
     """
     Axes.cla(self)
     self.xaxis.set_minor_locator(NullLocator())
     self.yaxis.set_minor_locator(NullLocator())
     self.xaxis.set_major_locator(NullLocator())
     self.yaxis.set_major_locator(NullLocator())
开发者ID:btel,项目名称:SpikeSort,代码行数:9,代码来源:_mpl_helpers.py


示例19: grid

    def grid(self, b=None, which='major', axis='both', **kwargs):
        Axes.grid(self, b, which, axis, **kwargs)

        plot_handler = GlobalFigureManager.get_active_figure().plot_handler
        if plot_handler is not None and not is_gui():
            if axis == 'x':
                plot_handler.manager._xgrid = b
            elif axis == 'y':
                plot_handler.manager._ygrid = b
开发者ID:mantidproject,项目名称:mslice,代码行数:9,代码来源:__init__.py


示例20: __init__

    def __init__(self, *args, **kwargs):
        self.ra_0 = None
        self.dec_0 = None
        self.dec_1 = None
        self.dec_2 = None

        Axes.__init__(self, *args, **kwargs)

        self.cla()
开发者ID:rainwoodman,项目名称:skymapper,代码行数:9,代码来源:aea_projection.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python backend_bases.key_press_handler函数代码示例发布时间:2022-05-27
下一篇:
Python axes.subplot_class_factory函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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