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

Python inset_locator.zoomed_inset_axes函数代码示例

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

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: zoomed_axis

def zoomed_axis(ax=plt.gca(),xlim=[None,None],ylim=[None,None],
                remove_ticks=True,zoom=1,borderpad=1,loc=4,**kw):
    """
    Creates a (pretty) zoomed axis
    
    Args:
        ax: which axis to zoom on
        <x/y>_lim: the axes limits
        remove_ticks: if true, removes the x and y ticks, to reduce clutter
        remaining args: passed to zoomed_inset_axes
    Returns:
        the inset axis
    """    
    axins = zoomed_inset_axes(ax, zoom=zoom, loc=loc,borderpad=borderpad)
    axins.set_xlim(*xlim) # apply the x-limits
    axins.set_ylim(*ylim) # apply the y-limits
    if (remove_ticks):
        PlotUtilities.no_x_anything(axins)
        PlotUtilities.no_y_anything(axins)
    return axins
开发者ID:prheenan,项目名称:GeneralUtil,代码行数:20,代码来源:Inset.py


示例17: pltimg

def pltimg(imname,loca,xl,xh,yh,yl,descrip):
    ## Main image
    ax=subplot(3,3,loca);
    ax.xaxis.set_visible(False)
    ax.yaxis.set_visible(False)
    ax.text(0.5,0.1,descrip,transform=ax.transAxes,color="white",weight='bold',horizontalalignment='center',fontsize=8)
    ax.imshow(imname,cmap="YlOrBr_r");
    axins=zoomed_inset_axes(ax,2,loc=1)
    axins.imshow(imname,cmap="YlOrBr_r");
    
    ## Inset
    x1, x2, y1, y2 = xl,xh,yh,yl
    axins.set_xlim(x1, x2)
    axins.set_ylim(y1, y2)
    axins.xaxis.set_visible(False)
    axins.yaxis.set_visible(False)
    axins.spines['bottom'].set_color('white')
    axins.spines['top'].set_color('white')
    axins.spines['left'].set_color('white')
    axins.spines['right'].set_color('white')
开发者ID:drphilmarshall,项目名称:SpaceWarps,代码行数:20,代码来源:simsfig.py


示例18: setup_inset_axes

def setup_inset_axes(parent_axes, f_hst, **kwargs):
    import mpl_toolkits.axes_grid1.inset_locator as inset_locator

    if "zoom" not in kwargs:
        kwargs["zoom"] = 4
    if "loc" not in kwargs:
        kwargs["loc"] = 1

    gh3 = pywcsgrid2.GridHelper(wcs=f_hst[0].header)

    axes_class = pywcsgrid2.Axes
    axes_kwargs=dict(grid_helper=gh3)

    ax3 = inset_locator.zoomed_inset_axes(parent_axes,
                                          axes_class=axes_class,
                                          axes_kwargs=axes_kwargs,
                                          **kwargs
                                          )

    ax3.axis[:].toggle(all=False)

    return ax3
开发者ID:leejjoon,项目名称:matplotlib_astronomy_gallery,代码行数:22,代码来源:tycho_hst_kpno.py


示例19: test_fill_facecolor

def test_fill_facecolor():
    fig, ax = plt.subplots(1, 5)
    fig.set_size_inches(5, 5)
    for i in range(1, 4):
        ax[i].yaxis.set_visible(False)
    ax[4].yaxis.tick_right()
    bbox = Bbox.from_extents(0, 0.4, 1, 0.6)

    # fill with blue by setting 'fc' field
    bbox1 = TransformedBbox(bbox, ax[0].transData)
    bbox2 = TransformedBbox(bbox, ax[1].transData)
    # set color to BboxConnectorPatch
    p = BboxConnectorPatch(
        bbox1, bbox2, loc1a=1, loc2a=2, loc1b=4, loc2b=3,
        ec="r", fc="b")
    p.set_clip_on(False)
    ax[0].add_patch(p)
    # set color to marked area
    axins = zoomed_inset_axes(ax[0], 1, loc='upper right')
    axins.set_xlim(0, 0.2)
    axins.set_ylim(0, 0.2)
    plt.gca().axes.get_xaxis().set_ticks([])
    plt.gca().axes.get_yaxis().set_ticks([])
    mark_inset(ax[0], axins, loc1=2, loc2=4, fc="b", ec="0.5")

    # fill with yellow by setting 'facecolor' field
    bbox3 = TransformedBbox(bbox, ax[1].transData)
    bbox4 = TransformedBbox(bbox, ax[2].transData)
    # set color to BboxConnectorPatch
    p = BboxConnectorPatch(
        bbox3, bbox4, loc1a=1, loc2a=2, loc1b=4, loc2b=3,
        ec="r", facecolor="y")
    p.set_clip_on(False)
    ax[1].add_patch(p)
    # set color to marked area
    axins = zoomed_inset_axes(ax[1], 1, loc='upper right')
    axins.set_xlim(0, 0.2)
    axins.set_ylim(0, 0.2)
    plt.gca().axes.get_xaxis().set_ticks([])
    plt.gca().axes.get_yaxis().set_ticks([])
    mark_inset(ax[1], axins, loc1=2, loc2=4, facecolor="y", ec="0.5")

    # fill with green by setting 'color' field
    bbox5 = TransformedBbox(bbox, ax[2].transData)
    bbox6 = TransformedBbox(bbox, ax[3].transData)
    # set color to BboxConnectorPatch
    p = BboxConnectorPatch(
        bbox5, bbox6, loc1a=1, loc2a=2, loc1b=4, loc2b=3,
        ec="r", color="g")
    p.set_clip_on(False)
    ax[2].add_patch(p)
    # set color to marked area
    axins = zoomed_inset_axes(ax[2], 1, loc='upper right')
    axins.set_xlim(0, 0.2)
    axins.set_ylim(0, 0.2)
    plt.gca().axes.get_xaxis().set_ticks([])
    plt.gca().axes.get_yaxis().set_ticks([])
    mark_inset(ax[2], axins, loc1=2, loc2=4, color="g", ec="0.5")

    # fill with green but color won't show if set fill to False
    bbox7 = TransformedBbox(bbox, ax[3].transData)
    bbox8 = TransformedBbox(bbox, ax[4].transData)
    # BboxConnectorPatch won't show green
    p = BboxConnectorPatch(
        bbox7, bbox8, loc1a=1, loc2a=2, loc1b=4, loc2b=3,
        ec="r", fc="g", fill=False)
    p.set_clip_on(False)
    ax[3].add_patch(p)
    # marked area won't show green
    axins = zoomed_inset_axes(ax[3], 1, loc='upper right')
    axins.set_xlim(0, 0.2)
    axins.set_ylim(0, 0.2)
    axins.get_xaxis().set_ticks([])
    axins.get_yaxis().set_ticks([])
    mark_inset(ax[3], axins, loc1=2, loc2=4, fc="g", ec="0.5", fill=False)
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:75,代码来源:test_axes_grid1.py


示例20: plotmustarsigma

    def plotmustarsigma(self, outputid = 0, zoomperc = 0.05, loc = 2):
        '''
        Plot the mu* vs sigma chart to interpret the combined effect of both.
        

        Parameters
        -----------
        zoomperc : float (0-1)
            the percentage of the output range to show in the zoomplot,
            if 'none', no zoom plot is added
        loc : int
            matplotlib.pyplot.legend: location code (0-10)
        outputid : int
            the output to use whe multiple are compared; starts with 0

        Returns
        ---------
        fig : matplotlib.figure.Figure object
            figure containing the output
        ax1 : axes.AxesSubplot object
            the subplot
        txtobjects : list of textobjects
            enbales the ad hoc replacement of labels when overlapping

        Notes
        -------
        Visualization as proposed by [M2]_
        '''

        mustar2use = self.mustar[outputid*self._ndim:(outputid+1)*self._ndim]
        sigma2use = self.sigma[outputid*self._ndim:(outputid+1)*self._ndim]

        fig = plt.figure()
        ax1 = fig.add_subplot(111)
        axs, txtobjects = scatterwithtext(ax1, mustar2use, sigma2use,
                                          self._namelist, 'ks', markersize = 8)

        ax1.set_xlabel(r'$\mu^*$', fontsize=20)
        ax1.set_ylabel(r'$\sigma$', fontsize=20)
        ax1.grid()
        ax1.yaxis.grid(linestyle = '--', color = '0.75')
        ax1.xaxis.grid(linestyle = '--', color = '0.75')
        ax1.set_xlim((0.0, mustar2use.max()+mustar2use.max()*0.1))
        ax1.set_ylim((0.0, sigma2use.max()+sigma2use.max()*0.1))

        majloc1 = MaxNLocator(nbins=4, prune='lower')
        ax1.yaxis.set_major_locator(majloc1)
        majloc2 = MaxNLocator(nbins=4)
        ax1.xaxis.set_major_locator(majloc2)

        if zoomperc != 'none':
            #the zooming box size is ad hoc and can be improved
            axins = zoomed_inset_axes(ax1, np.floor(1./zoomperc/2.5),
                                      loc = loc)

            axins.plot(mustar2use, sigma2use, 'ks', markersize = 3)
            transOffset2 = offset_copy(axins.transData, fig=plt.gcf(),
                                       x = -0.05, y=0.10, units='inches')
            #plot in the subplot
            ct2=0
            txtobjects2=[]
            for x, y in zip(mustar2use, sigma2use):
                if x < mustar2use.max()*zoomperc and y < sigma2use.max()*zoomperc:
                    axins.plot((x,),(y,), 'ks', markersize = 3)
                    ls = axins.text(x, y, '%s' %self._namelist[ct2],
                                  transform=transOffset2, color='k')
                    txtobjects2.append(ls)
                ct2+=1

            #zoomplot with labels right
            axins.yaxis.set_ticks_position('right')
            #set the limits of the zoom plot
            axins.set_xlim((0.0, mustar2use.max()*zoomperc))
            axins.set_ylim((0.0, sigma2use.max()*zoomperc))
            #only minor number of ticks for cleaner overview
            majloc3 = MaxNLocator(nbins=3, prune='lower')
            axins.yaxis.set_major_locator(majloc3)
            majloc4 = MaxNLocator(nbins=3, prune='lower')
            axins.xaxis.set_major_locator(majloc4)
            #smaller size for the ticklabels (different is actually not needed)
            for tickx in axins.xaxis.get_major_ticks():
                tickx.label.set_fontsize(10)
            for label in axins.yaxis.get_majorticklabels():
                label.set_fontsize(10)
                label.set_rotation('vertical')

            #create the subarea-plot in main frame and connect
            mark_inset(ax1, axins, loc1=2, loc2=4, fc='none', ec='0.8')
            axins.grid()
            axins.yaxis.grid(linestyle = '--', color = '0.85')
            axins.xaxis.grid(linestyle = '--', color = '0.85')
        return fig, ax1, txtobjects
开发者ID:stijnvanhoey,项目名称:pystran,代码行数:92,代码来源:sensitivity_morris.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python basemap.addcyclic函数代码示例发布时间:2022-05-27
下一篇:
Python inset_locator.mark_inset函数代码示例发布时间: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