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


Python inset_locator.zoomed_inset_axes函数代码示例

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


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

示例1: test_zooming_with_inverted_axes

def test_zooming_with_inverted_axes():
    fig, ax = plt.subplots()
    ax.plot([1, 2, 3], [1, 2, 3])
    ax.axis([1, 3, 1, 3])
    inset_ax = zoomed_inset_axes(ax, zoom=2.5, loc='lower right')
    inset_ax.axis([1.1, 1.4, 1.1, 1.4])

    fig, ax = plt.subplots()
    ax.plot([1, 2, 3], [1, 2, 3])
    ax.axis([3, 1, 3, 1])
    inset_ax = zoomed_inset_axes(ax, zoom=2.5, loc='lower right')
    inset_ax.axis([1.4, 1.1, 1.4, 1.1])
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:12,代码来源:test_axes_grid1.py

示例2: plot_us

def plot_us(lats, lons, save_name=None):
    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(111)
    big_map = Basemap(resolution='h',
                      lat_0=36, lon_0=-107.5,
                      llcrnrlat=32, llcrnrlon=-125,
                      urcrnrlat=43, urcrnrlon=-110)
    big_map.drawcoastlines()
    big_map.drawstates()
    big_map.drawcountries()
    big_map.drawmapboundary(fill_color='#7777ff')
    big_map.fillcontinents(color='#ddaa66', lake_color='#7777ff', zorder=0)
    x, y = big_map(lons, lats)
    big_map.plot(x[0], y[0], 'ro', markersize=2)

    axins = zoomed_inset_axes(ax, 20, loc=1)
    ll_lat, ll_lon = 37.8, -122.78
    ur_lat, ur_lon = 38.08, -122.43

    axins.set_xlim(ll_lon, ur_lon)
    axins.set_ylim(ur_lon, ur_lat)

    small_map = Basemap(resolution='h',
                        llcrnrlat=ll_lat, llcrnrlon=ll_lon,
                        urcrnrlat=ur_lat, urcrnrlon=ur_lon,
                        ax=axins)
    small_map.drawcoastlines()
    small_map.drawmapboundary(fill_color='#7777ff')
    small_map.fillcontinents(color='#ddaa66', lake_color='#7777ff', zorder=0)
    x, y = small_map(lons, lats)
    small_map.plot(x, y, 'ro', markersize=3)

    mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")
    if save_name: 
        fig.savefig(save_name)
开发者ID:Ultramann,项目名称:Stravaboards,代码行数:35,代码来源:plot_segments.py

示例3: plot_linear_kernel_pairs

def plot_linear_kernel_pairs(pairs):
    xdata, ydata = zip(*pairs)
    maxval = max(max(xdata), max(ydata))

    fig, ax = plt.subplots()
    ax.plot(xdata, ydata, '.')
    ax.plot([0, maxval], [0, maxval], '--')
    plt.xlabel("Linear Ridge Mean Absolute Error (kcal/mol)")
    plt.ylabel("Kernel Ridge Mean Absolute Error (kcal/mol)")

    # 15 is the zoom, loc is nuts
    axins = zoomed_inset_axes(ax, 15, loc=5)
    axins.plot(xdata, ydata, '.')
    axins.plot([0, maxval], [0, maxval], '--')

    # sub region of the original image
    axins.set_xlim(1, 6)
    axins.set_ylim(1, 6)

    # draw a bbox of the region of the inset axes in the parent axes and
    # connecting lines between the bbox and the inset axes area
    mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")

    plt.draw()
    plt.show()
开发者ID:vinodrajendran001,项目名称:ml_research,代码行数:25,代码来源:paper_plots.py

示例4: plot_target_pred

def plot_target_pred(train_xdata, test_xdata, train_ydata, test_ydata, loc=5):
    maxval = max(train_xdata.max(), test_xdata.max(), train_ydata.max(), test_ydata.max())
    minval = min(train_xdata.min(), test_xdata.min(), train_ydata.min(), test_ydata.min())

    fig, ax = plt.subplots()
    ax.plot(train_xdata, train_ydata, '.', label="Train")
    ax.plot(test_xdata, test_ydata, '.', label="Test")
    plt.legend(loc="best")
    ax.plot([minval, maxval], [minval, maxval], '--')
    plt.xlabel("Target Value (kcal/mol)")
    plt.ylabel("Predicted Value (kcal/mol)")

    axins = zoomed_inset_axes(ax, 30, loc=loc) # 30 is zoom, loc is .... nuts
    axins.plot(train_xdata, train_ydata, '.', label="Train")
    axins.plot(test_xdata, test_ydata, '.', label="Test")
    axins.plot([minval, maxval], [minval, maxval], '--')
    # sub region of the original image
    middle = test_xdata.mean() - 170
    x1, x2, y1, y2 = -15+middle, 15+middle, -15+middle, 15+middle
    axins.set_xlim(x1, x2)
    axins.set_ylim(y1, y2)

    mark_inset(ax, axins, loc1=2, loc2=3, fc="none", ec="0.5")
    plt.draw()
    plt.show()
开发者ID:vinodrajendran001,项目名称:ml_research,代码行数:25,代码来源:paper_plots.py

示例5: inset_momentum_axes

    def inset_momentum_axes(cd):

        # TODO: This plot does not refresh correctly, skip the inset
        fig = mpl.figure(cd.plotfigure.figno)
        axes = fig.add_subplot(111)

        # Plot main figure
        axes.plot(cd.x, hu_1(cd), 'b-')
        axes.plot(cd.x, hu_2(cd), 'k--')
        axes.set_xlim(xlimits)
        axes.set_ylim(ylimits_momentum)
        momentum_axes(cd)

        # Create inset plot
        from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
        from mpl_toolkits.axes_grid1.inset_locator import mark_inset
        inset_axes = zoomed_inset_axes(axes, 0.5, loc=3)
        inset_axes.plot(cd.x, hu_1(cd), 'b-')
        inset_axes.plot(cd.x, hu_2(cd), 'k--')
        inset_axes.set_xticklabels([])
        inset_axes.set_yticklabels([])
        x_zoom = [-120e3,-30e3]
        y_zoom = [-10,10]
        inset_axes.set_xlim(x_zoom)
        inset_axes.set_ylim(y_zoom)
        mark_inset(axes, inset_axes, loc1=2, loc2=4, fc='none', ec="0.5")
        # mpl.ion()
        mpl.draw()
开发者ID:dlgeorge,项目名称:apps,代码行数:28,代码来源:setplot_shelf.py

示例6: render_input_spectrum

def render_input_spectrum():

    folder = "/cosma/home/durham/rhgk18/ls_structure/pks"
    bao    = folder+"/wig.txt"
    nbao   = folder+"/nowig.txt"

    pkbao  = np.loadtxt(bao)
    pknbao = np.loadtxt(nbao)

    fig, ax = plt.subplots()

    ax.loglog(pkbao[:,0]  ,pkbao[:,1]  , color='r', label='With BAO')
    ax.loglog(pknbao[:,0] ,pknbao[:,1] , color='b', label='Without BAO')
    ax.set_xlabel("Wavenumber, $k$ [$h/Mpc$]", size=28)
    ax.set_ylabel("Power, $P(k)$ [$(Mpc/h)^3$]", size=28)
    ax.legend(prop={'size':28})
    
    axins = zoomed_inset_axes(ax, 5, loc=3)
    axins.loglog(pkbao[:,0]  ,pkbao[:,1]  , color='r', label='iWith BAO')
    axins.loglog(pknbao[:,0] ,pknbao[:,1] , color='b', label='iWithout BAO')

    x1, x2, y1, y2 = 0.02, 0.1, 5000, 30000
    axins.set_xlim(x1, x2)
    axins.set_ylim(y1, y2)

    plt.xticks(visible=False)
    plt.yticks(visible=False)

    mark_inset(ax, axins, loc1=2, loc2=1, fc="none", ec="0.5")

    
    plt.show()
开发者ID:samhumphriss,项目名称:ls_structure,代码行数:32,代码来源:input_spectrum.py

示例7: setup_axes02

def setup_axes02(fig, rect, zoom=0.35, loc=4, axes_class=None, axes_kwargs=None):
    """
    ax2 is an inset axes, but shares the x- and y-axis with ax1.
    """

    from mpl_toolkits.axes_grid1.axes_grid import ImageGrid, CbarAxes
    import mpl_toolkits.axes_grid1.inset_locator as inset_locator

    grid = ImageGrid(fig, rect,
                     nrows_ncols=(1,1),
                     share_all=True, aspect=True,
                     label_mode='L', cbar_mode="each",
                     cbar_location='top', cbar_pad=None, cbar_size='5%',
                     axes_class=(axes_class, axes_kwargs))

    ax1 = grid[0]

    kwargs = dict(zoom=zoom, loc=loc)
    ax2 = inset_locator.zoomed_inset_axes(ax1,
                                          axes_class=axes_class,
                                          axes_kwargs=axes_kwargs,
                                          **kwargs
                                          )


    cax = inset_locator.inset_axes(ax2, "100%", 0.05, loc=3,
                                   borderpad=0.,
                                   bbox_to_anchor=(0, 0, 1, 0),
                                   bbox_transform=ax2.transAxes,
                                   axes_class=CbarAxes,
                                   axes_kwargs=dict(orientation="top"),
                                   )

    ax2.cax = cax
    return grid[0], ax2
开发者ID:leejjoon,项目名称:matplotlib_astronomy_gallery,代码行数:35,代码来源:tycho_hst_kpno.py

示例8: create_inset_axes

    def create_inset_axes(self):
        ax_inset = zoomed_inset_axes(self.ax, 2, loc=1)

        cm = plt.get_cmap('winter')
        ax_inset.set_color_cycle([cm(1.*i/self.num_graphs)
                                 for i in range(self.num_graphs)])

        # hide every other tick label
        for label in ax_inset.get_xticklabels()[::4]:
            label.set_visible(False)

        return ax_inset
开发者ID:LSDtopotools,项目名称:LSDPlotting,代码行数:12,代码来源:Boscastle_rainfall_ensemble_hydro.py

示例9: test_gettightbbox

def test_gettightbbox():
    fig, ax = plt.subplots(figsize=(8, 6))

    l, = ax.plot([1, 2, 3], [0, 1, 0])

    ax_zoom = zoomed_inset_axes(ax, 4)
    ax_zoom.plot([1, 2, 3], [0, 1, 0])

    mark_inset(ax, ax_zoom, loc1=1, loc2=3, fc="none", ec='0.3')

    remove_ticks_and_titles(fig)
    bbox = fig.get_tightbbox(fig.canvas.get_renderer())
    np.testing.assert_array_almost_equal(bbox.extents,
                                         [-17.7, -13.9, 7.2, 5.4])
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:14,代码来源:test_axes_grid1.py

示例10: makeplot

def makeplot(refl, winds, w, stride, map, gs, title, file_name, box=None):
    pylab.figure()
    axmain = pylab.axes((0, 0.025, 1, 0.9))

    gs_x, gs_y = gs
    nx, ny = refl.shape
    xs, ys = np.meshgrid(gs_x * np.arange(nx), gs_y * np.arange(ny))

    pylab.contourf(xs, ys, refl, levels=np.arange(10, 80, 10))
    pylab.colorbar()
    pylab.contour(xs, ys, w, levels=np.arange(-10, 0, 2), colors='#666666', style='--')
    pylab.contour(xs, ys, w, levels=np.arange(2, 12, 2), colors='#666666', style='-')
    
    u, v = winds
    wind_slice = tuple([ slice(None, None, stride) ] * 2)
    pylab.quiver(xs[wind_slice], ys[wind_slice], u[wind_slice], v[wind_slice])

    if box:
        lb_y, lb_x = [ b.start for b in box ]
        ub_y, ub_x = [ b.stop for b in box ]

        box_xs = gs_x * np.array([ lb_x, lb_x, ub_x, ub_x, lb_x])
        box_ys = gs_y * np.array([ lb_y, ub_y, ub_y, lb_y, lb_y])

        map.plot(box_xs, box_ys, '#660099')

        axins = zoomed_inset_axes(pylab.gca(), 4, loc=4)
        pylab.sca(axins)

        pylab.contourf(xs[box], ys[box], refl[box], levels=np.arange(10, 80, 10))
        pylab.contour(xs[box], ys[box], w[box], levels=np.arange(-10, 0, 2), colors='#666666', style='--')
        pylab.contour(xs[box], ys[box], w[box], levels=np.arange(2, 12, 2), colors='#666666', style='-')
        pylab.quiver(xs[box], ys[box], u[box], v[box])

        drawPolitical(map)

        pylab.xlim([lb_x * gs_x, ub_x * gs_x - 1])
        pylab.ylim([lb_y * gs_y, ub_y * gs_y - 1])

        mark_inset(axmain, axins, loc1=1, loc2=3, fc='none', ec='k')

    pylab.sca(axmain)
    drawPolitical(map)

    pylab.suptitle(title)
    pylab.savefig(file_name)
    pylab.close()
    return
开发者ID:tsupinie,项目名称:research,代码行数:48,代码来源:plot_mean.py

示例11: test_inset_locator

def test_inset_locator():
    def get_demo_image():
        from matplotlib.cbook import get_sample_data
        import numpy as np
        f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
        z = np.load(f)
        # z is a numpy array of 15x15
        return z, (-3, 4, -4, 3)

    fig, ax = plt.subplots(figsize=[5, 4])

    # prepare the demo image
    Z, extent = get_demo_image()
    Z2 = np.zeros([150, 150], dtype="d")
    ny, nx = Z.shape
    Z2[30:30 + ny, 30:30 + nx] = Z

    # extent = [-3, 4, -4, 3]
    ax.imshow(Z2, extent=extent, interpolation="nearest",
              origin="lower")

    axins = zoomed_inset_axes(ax, zoom=6, loc='upper right')
    axins.imshow(Z2, extent=extent, interpolation="nearest",
                 origin="lower")
    axins.yaxis.get_major_locator().set_params(nbins=7)
    axins.xaxis.get_major_locator().set_params(nbins=7)
    # sub region of the original image
    x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
    axins.set_xlim(x1, x2)
    axins.set_ylim(y1, y2)

    plt.xticks(visible=False)
    plt.yticks(visible=False)

    # draw a bbox of the region of the inset axes in the parent axes and
    # connecting lines between the bbox and the inset axes area
    mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")

    asb = AnchoredSizeBar(ax.transData,
                          0.5,
                          '0.5',
                          loc='lower center',
                          pad=0.1, borderpad=0.5, sep=5,
                          frameon=False)
    ax.add_artist(asb)
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:45,代码来源:test_axes_grid1.py

示例12: plotConfusion

def plotConfusion(confusion, grid, title, file_name, inset=None, fudge=16):
    pylab.figure()
    axmain = pylab.axes()

    tick_labels = [ "Missing", "Correct\nNegative", "False\nAlarm", "Miss", "Hit" ]
    min_label = -1

    xs, ys = grid.getXY()

    pylab.pcolormesh(xs, ys, confusion, cmap=confusion_cmap, vmin=min_label, vmax=(min_label + len(tick_labels) - 1))

    tick_locs = np.linspace(-1, min_label + len(tick_labels) - 2, len(tick_labels))
    tick_locs += (tick_locs[1] - tick_locs[0]) / 2
    bar = pylab.colorbar()
    bar.locator = FixedLocator(tick_locs)
    bar.formatter = FixedFormatter(tick_labels)
    pylab.setp(pylab.getp(bar.ax, 'ymajorticklabels'), fontsize='large')
    bar.update_ticks()

    grid.drawPolitical()

    if inset:
        lb_y, lb_x = [ b.start for b in inset ]
        ub_y, ub_x = [ b.stop + fudge for b in inset ]

        inset_exp = (slice(lb_y, ub_y), slice(lb_x, ub_x))

        axins = zoomed_inset_axes(pylab.gca(), 2, loc=4)
        pylab.sca(axins)

        pylab.pcolormesh(xs[inset_exp], ys[inset_exp], confusion[inset_exp], cmap=confusion_cmap, vmin=min_label, vmax=(min_label + len(tick_labels) - 1))
        grid.drawPolitical()

        gs_x, gs_y = grid.getGridSpacing()

        pylab.xlim([lb_x * gs_x, (ub_x - 1) * gs_x])
        pylab.ylim([lb_y * gs_y, (ub_y - 1) * gs_y])

        mark_inset(axmain, axins, loc1=1, loc2=3, fc='none', ec='k')

    pylab.sca(axmain)
    pylab.suptitle(title)
    pylab.savefig(file_name)
    pylab.close()
    return
开发者ID:tsupinie,项目名称:research,代码行数:45,代码来源:plot_confusion.py

示例13: draw_inset

def draw_inset(plt, m, pos, lat, lon):
    ax = plt.subplot(111)
    zoom = 50
    axins = zoomed_inset_axes(ax, zoom, loc=1)
    m.plot(lon, lat, '.b--', zorder=10, latlon=True)
    m.scatter(lon, lat,  # longitude first!
              latlon=True,  # lat and long in degrees
              zorder=11)  # on top of all
    x1, y1 = m(lon[1] - 0.005, lat[0] - 0.0025)
    x2, y2 = m(lon[1] + 0.005, lat[0] + 0.0025)
    axins.set_xlim(x1, x2)
    axins.set_ylim(y1, y2)

    plt.xticks(visible=False)
    plt.yticks(visible=False)
    # draw a bbox of the region of the inset axes in the parent axes and
    # connecting lines between the bbox and the inset axes area
    mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")
开发者ID:kirienko,项目名称:pylgrim,代码行数:18,代码来源:map.py

示例14: plot_calibration

def plot_calibration(c, insert = True):
    fig = plt.figure()
    ax = plt.gca()
    for baseline, correlation in c.time_domain_correlations_values.items():
        correlation_max_val = correlation[np.argmax(correlation)]
        correlation_max_time = c.time_domain_correlations_times[baseline][np.argmax(correlation)]
        lines = ax.plot(
            c.time_domain_correlations_times[baseline] * 1e9,
            correlation / correlation_max_val,
            label = baseline)
        #ax.plot([correlation_max_time, correlation_max_time], [0, correlation_max_val], color = lines[0].get_color())
    ax.set_ylim(top=1.2)
    ax.xaxis.set_ticks(np.arange(
        -200,
        200,
        2))
    if insert == True:
        #axins = zoomed_inset_axes(ax, 5, loc=1)
        axins = zoomed_inset_axes(ax, 9, loc=1)
        for baseline, correlation in c.time_domain_correlations_values.items():
            correlation_max_val = correlation[np.argmax(correlation)]
            correlation_max_time = c.time_domain_correlations_times[baseline][np.argmax(correlation)]
            lines = axins.plot(
                c.time_domain_correlations_times[baseline] * 1e9,
                correlation / correlation_max_val,
                label = baseline,
                linewidth=2)
            #axins.plot([correlation_max_time, correlation_max_time], [0, correlation_max_val], color = lines[0].get_color())
        #axins.set_xlim(-0.4, 2.9)
        axins.set_xlim(-0.4, 0.4)
        #axins.set_ylim(0.90, 1.04)
        axins.set_ylim(0.96, 1.03)
        #axins.xaxis.set_ticks(np.arange(-0.4, 2.9, 0.4))
        axins.xaxis.set_ticks(np.arange(-0.4, 0.4, 0.2))
        mark_inset(ax, axins, loc1=2, loc2=3, fc='none', ec='0.5')

    plt.xticks(visible=True)
    plt.yticks(visible=False)
    ax.set_title("Time domain cross correlations with broad band noise\n arriving through full RF chain AFTER calibration")
    ax.set_xlabel("Time delay (ns)")
    ax.set_ylabel("Cross correlation value (normalised)")
    ax.legend(loc=2)
    #ax.legend()
    plt.show()
开发者ID:jgowans,项目名称:directionFinder_backend,代码行数:44,代码来源:calibrate_time_domain.py

示例15: plot_site

def plot_site(options):
    options['prefix'] = 'site'
    fig = MyFig(options, figsize=(10, 8), legend=True, grid=False, xlabel=r'Probability $p_s$', ylabel=r'Reachability~$\reachability$', aspect='auto')
    fig_vs = MyFig(options, figsize=(10, 8), legend=True, grid=False, xlabel=r'Fraction of Forwarded Packets~$\forwarded$', ylabel=r'Reachability~$\reachability$', aspect='auto')

    if options['grayscale']:
        colors = options['graycm'](pylab.linspace(0, 1.0, 3))
    else:
        colors = fu_colormap()(pylab.linspace(0, 1.0, 3))
    nodes = 105

    axins = None
    if options['inset_loc'] >= 0:
        axins = zoomed_inset_axes(fig_vs.ax, options['inset_zoom'], loc=options['inset_loc'])
        axins.set_xlim(options['inset_xlim'])
        axins.set_ylim(options['inset_ylim'])
        axins.set_xticklabels([])
        axins.set_yticklabels([])
        mark_inset(fig_vs.ax, axins, loc1=2, loc2=3, fc="none", ec="0.5")

    for i, (name, label) in enumerate(names):
        data = parse_site_only(options['datapath'][0], name)
        rs = numpy.array([r for p, r, std, conf, n, fw, fw_std, fw_conf in data if r <= options['limit']])
        fws = numpy.array([fw for p, r, std, conf, n, fw, fw_std, fw_conf in data if r <= options['limit']])/(nodes-1)
        ps = numpy.array([p for p, r, std, conf, n, fw, fw_std, fw_conf in data]) #[0:len(rs)])
        yerr = numpy.array([conf for p,r,std,conf, n, fw, fw_std, fw_conf in data]) #[0:len(rs)])

        patch_collection = PatchCollection([conf2poly(ps, list(rs+yerr), list(rs-yerr), color=colors[i])], match_original=True)
        patch_collection.set_alpha(0.3)
        patch_collection.set_linestyle('dashed')
        fig.ax.add_collection(patch_collection)

        fig.ax.plot(ps, rs, label=label, color=colors[i])
        fig_vs.ax.plot(fws, rs, label=label, color=colors[i])
        if axins:
            axins.plot(fws, rs, color=colors[i])

    fig.ax.set_ylim(0, options['limit'])
    fig.legend_title = 'Graph'
    fig.save('graphs')
    fig_vs.legend_title = 'Graph'
    fig_vs.ax.set_xlim(0,1)
    fig_vs.ax.set_ylim(0,1)
    fig_vs.save('vs_pb')
开发者ID:Dekue,项目名称:des-routing-algorithms,代码行数:44,代码来源:plot_simu.py


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