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

Python pyplot.interactive函数代码示例

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

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



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

示例1: plotResults

def plotResults(results):
    plt.interactive(True)
    plt.subplot(131)
    plt.plot(results.xpos, color='b',label='X Position')
    plt.plot(results.ypos, linestyle='--', color='r', label='Y Position')
    plt.plot(results.zpos, linestyle='-', color='y', label='Z Position')
    plt.xlabel('Time')
    plt.ylabel('Distance')
    plt.title('Distance Traveled')
    plt.legend()
    plt.show()

    ts = range(0,len(results),6)
    plt.subplot(131)
    pt = plt.plot(0,results.zpos[0], 'ro', markersize=4)
    for t in ts:
        plt.subplot(131)
        pt[0].set_ydata(results.zpos[t])
        pt[0].set_xdata(t)
        ax1 = plt.subplot(132)
        ax1.clear()
        plt.bar(range(6), results[t].lowerleglinearmag)
        ax2 = plt.subplot(133)
        ax2.clear()
        plt.bar(range(6), results[t].upperleglinearmag)
        plt.draw()
        time.sleep(0.01)
开发者ID:henryeherman,项目名称:BulletXcodeDemos,代码行数:27,代码来源:demoarr.py


示例2: print_all

def print_all(fnames, freq, spec1, spec2, rms1, rms2, bw=(0,1600)):
    '''
    Print all power spectra to PDF files
    '''
    # Construct path for saving figures and notify
    base_dir = os.path.join(os.getcwd(), 'figures')
    if not os.path.exists(base_dir):
        os.mkdir(base_dir)
    print('\nsaving figures to {s} ... '.format(s=base_dir), flush=True)

    # Plot and save figures for each channel's spectrum
    on = plt.isinteractive()
    plt.ioff()
    for chan in range(spec1.shape[-1]):
        fig = comp_spectra(freq, spec1, spec2, channel=chan, bw=bw)
        plt.title('Channel {0:d}'.format(chan))
        plt.xlabel('Frequency (Hz)')
        plt.ylabel('Power')
        plt.legend(('Before', 'After'))
        print('figure {:02d}'.format(chan), flush=True)
        plt.savefig(os.path.join(base_dir, 'channel{0:02d}.png'.format(chan)), format='png')
        plt.close(fig)

    # Plot and save figure showing RMS ratio
    fig = plt.figure()
    plt.plot(rms2 / rms1, 'o')
    plt.title('RMS ratio (after / before)')
    plt.xlabel('Channel')
    plt.savefig(os.path.join(base_dir, 'rms_ratio.png'), format='png')
    plt.close(fig)

    # Notify
    plt.interactive(on)
    print('done.')
开发者ID:baccuslab,项目名称:plat,代码行数:34,代码来源:plat.py


示例3: lvmTwoDPlot

def lvmTwoDPlot(X, lbl=None, symbol=None):

    """Helper function for plotting the labels in 2-D.
    
    Description:
    
    lvmTwoDPlot(X, lbl, symbol) helper function for plotting an
     embedding in 2-D with symbols.
     Arguments:
      X - the data to plot.
      lbl - the labels of the data point.
      symbol - the symbols to use for the different labels.
        

    See also
    lvmScatterPlot, lvmVisualise


    Copyright (c) 2004, 2005, 2006, 2008, 2009 Neil D. Lawrence
    
    """

    if lbl=='connect':
        connect = True
        lbl = None
    else:
        connect = False
    
    if symbol is None:
        if lbl is None:
            symbol = ndlutil.getSymbols(1)
        else:
            symbol = ndlutil.getSymbols(lbl.shape[1])
    axisHand = pp.gca()
    returnVal = []
    holdState = axisHand.ishold()
    intState = pp.isinteractive()
    pp.interactive(False)
    for i in range(X.shape[0]):
        if i == 1:
            axisHand.hold(True)
        if lbl is not None:
            labelNo = np.flatnonzero(lbl[i])
        else:
            labelNo = 0

        try:
            returnVal.append(axisHand.plot([X[i, 0]], [X[i, 1]], symbol[labelNo], markersize=10, linewidth=2))
            if connect:
                if i>0:
                    axisHand.plot([X[i-1, 0], X[i, 0]], [X[i-1, 1], X[i, 1]], 'r')
            
        except(NotImplementedError):
            raise NotImplementedError('Only '+ str(len(symbol)) + ' labels supported (it''s easy to add more!)')
    axisHand.hold(holdState)
    if intState:
        pp.show()
    pp.interactive(intState)
    
    return returnVal
开发者ID:lawrennd,项目名称:mltools,代码行数:60,代码来源:mltools.py


示例4: plot_gamma_1_storage

def plot_gamma_1_storage():
	plt.figure()
	ts=get_mismatch(1.0)
	dummy,storage_capacity,storage_level=get_policy_2_storage(ts,return_storage_filling_time_series=True)
	plt.plot(storage_level)
	plt.interactive(1)
	plt.show()
开发者ID:TueVJ,项目名称:stBaCU,代码行数:7,代码来源:tplot.py


示例5: plot_path2d

def plot_path2d(data1, data2, data3, data4):
    x1=[x for [x, y, z] in data1]
    y1=[y for [x, y, z] in data1]
    z1=[z for [x, y, z] in data1]

    x2=[x for [x, y, z] in data2]
    y2=[y for [x, y, z] in data2]
    z2=[z for [x, y, z] in data2]

    mx1=[x for [x, y, z] in data3]
    my1=[y for [x, y, z] in data3]
    mz1=[z for [x, y, z] in data3]

    mx2=[x for [x, y, z] in data4]
    my2=[y for [x, y, z] in data4]
    mz2=[z for [x, y, z] in data4]

    pltxy=plt.plot(x1,y1, 'ro-',label='xy')
    pltuv=plt.plot(x2,y2, 'bs-',label='uv')
    mpltxy=plt.plot(mx1,my1, 'go-',label='cut_xy')
    mpltuv=plt.plot(mx2,my2, 'ks-',label='cut_uv')

    plt.legend()
    plt.axis('equal')
    plt.axis([min([min(x1),min(x2),min(mx1),min(mx2)]),\
              max([max(x1),max(x2),max(mx1),max(mx2)]),\
              min([min(y1),min(y2),min(my1),min(my2)]),\
              max([max(y1),max(y2),max(my1),max(my2)])])
    plt.grid(True)
    plt.interactive(True)
    plt.show(block=False)
#   plt.show()

    plt.hold(True)
开发者ID:FoamWorkshop,项目名称:cncfc,代码行数:34,代码来源:knots2plot.py


示例6: cosp_plot_column_2D

def cosp_plot_column_2D(fnc, varname='equivalent_reflectivity_factor', level=0, column = 0, time = 0):
    """
    Function that plots one column of lat/lon data.
    """

    plt.interactive(True)
    fig=plt.figure()
    ax = fig.add_subplot(111)
    # Read cube
    z=iris.load(fnc)
    z=z[0]

    # Get coords
    c = z.coord('column')
    t = z.coord('time')

    # Select time and column
    y=z.extract(iris.Constraint(column=c.points[column]))
    y=y.extract(iris.Constraint(time=t.points[time]))
    # Select level. Not managed to make constrain with 'atmospheric model level'
    y=y[level]

    color_map = mpl_cm.get_cmap('Paired')
    qplt.pcolormesh(y,cmap=color_map,vmin=-20,vmax=20)
    plt.gca().coastlines()

    return
开发者ID:CFMIP,项目名称:COSPv1,代码行数:27,代码来源:COSP_plots.py


示例7: plot_data_dict

def plot_data_dict(data_dict, plots = None, mode = 'static', hang = True, figure = None, size = None, **plot_preference_kwargs):
    """
    Make a plot of data in the format defined in data_dict
    :param data_dict: dict<str: plottable_data>
    :param plots: Optionally, a dict of <key: IPlot> identifying the plot objects to use (keys should
        be the same as those in data_dict).
    :return: The plots (same ones you provided if you provided them)
    """

    assert mode in ('live', 'static')
    if isinstance(data_dict, list):
        assert all(len(d) == 2 for d in data_dict), "You can provide data as a list of 2 tuples of (plot_name, plot_data)"
        data_dict = OrderedDict(data_dict)

    if plots is None:
        plots = {k: get_plot_from_data(v, mode = mode, **plot_preference_kwargs) for k, v in data_dict.items()}

    if figure is None:
        if size is not None:
            from pylab import rcParams
            rcParams['figure.figsize'] = size
        figure = plt.figure()
    n_rows, n_cols = vector_length_to_tile_dims(len(data_dict))
    for i, (k, v) in enumerate(data_dict.items()):
        plt.subplot(n_rows, n_cols, i + 1)
        plots[k].update(v)
        plots[k].plot()
        plt.title(k, fontdict = {'fontsize': 8})
    oldhang = plt.isinteractive()
    plt.interactive(not hang)
    plt.show()
    plt.interactive(oldhang)
    return figure, plots
开发者ID:QUVA-Lab,项目名称:artemis,代码行数:33,代码来源:easy_plotting.py


示例8: plot_paths

def plot_paths(results, which_to_label=None):
    import matplotlib
    import matplotlib.pyplot as plt
    plt.clf()
    interactive_state = plt.isinteractive()
    xvalues = -np.log(results.lambdas[1:])
    for index, path in enumerate(results.coefficients):
        if which_to_label and results.indices[index] in which_to_label:
            if which_to_label[results.indices[index]] is None:
                label = "$x_{%d}$" % results.indices[index]
            else:
                label = which_to_label[results.indices[index]]
        else:
            label = None


        if which_to_label and label is None:
            plt.plot(xvalues, path[1:], ':')
        else:
            plt.plot(xvalues, path[1:], label=label)

    plt.xlim(np.amin(xvalues), np.amax(xvalues))

    if which_to_label is not None:
        plt.legend(loc='upper left')
    plt.title('Regularization paths ($\\rho$ = %.2f)' % results.balance)
    plt.xlabel('$-\log(\lambda)$')
    plt.ylabel('Value of regression coefficient $\hat{\\beta}_i$')
    plt.show()
    plt.interactive(interactive_state)
开发者ID:samuelstjean,项目名称:glmnet-python,代码行数:30,代码来源:glmnet.py


示例9: get_windows

def get_windows(image):
    """Display the given image and record user selected points.

    Parameters
    ----------

    image : M,N,3 ndarray
        The image to be displayed.

    Returns
    -------

    array : n_points,2
        An array of coordinates in the image. Each row corresponds to the x, y
        coordinates of one point. If an odd number of points are specified, the
        last one will be discarded.

    """
    plt.interactive(True)
    plt.imshow(image)
    plt.show()
    crop = plt.ginput(0)
    plt.close()
    plt.interactive(False)
    # remove last point if an odd number selected
    crop = crop[:-1] if np.mod(len(crop), 2) else crop
    return np.vstack(crop).astype('int')[:, [1, 0]]
开发者ID:SamHames,项目名称:aperturesynth,代码行数:27,代码来源:gui.py


示例10: draw_2D_slice_interactive

def draw_2D_slice_interactive(self, p_vals, x_variable, y_variable,
                              range_x, range_y, slider_ranges,
                              **kwargs):
    previous = plt.isinteractive()
    plt.ioff()
    number_of_sliders = len(slider_ranges)
    slider_block = 0.03*number_of_sliders
    fig = plt.figure()
    plt.clf()
    ax = plt.axes([0.1, 0.2+slider_block, 0.8, 0.7-slider_block])
    c_axs = list()
    cdict = dict()
    if 'color_dict' in kwargs:
        cdict.update(kwargs['color_dict'])
    j = 0
    sliders = dict()
    for i in slider_ranges:
        slider_ax = plt.axes([0.1, 0.1+j*0.03, 0.8, 0.02])
        slider = Slider(slider_ax, i, 
                        log10(slider_ranges[i][0]), log10(slider_ranges[i][1]), 
                        valinit=log10(p_vals[i]), color='#AAAAAA'
                        )
        j += 1
        sliders[i] = slider
    update = SliderCallback(self, sliders, c_axs, cdict, 
                            ax, p_vals, x_variable, y_variable, range_x, range_y,
                            **kwargs)
    update(1)
    for i in sliders:
        sliders[i].on_changed(update)
    plt.show()
    plt.interactive(previous)
开发者ID:jlomnitz,项目名称:python-design-space-interface,代码行数:32,代码来源:designspace_plot.py


示例11: train_agent

def train_agent(mdp, agent, max_episodes, epsilon_decay=0.9, plot=False):
    '''
    Trains an agent on the given MDP for the specified number of episodes.

    :param mdp: The mdp which implements the domain
    :param agent: The RL agent to train
    :param max_episodes: The maximum number of episodes to run
    :param epsilon_decay: The per-episode decay rate of the epsilon parameter
    :param plot: If true, plot the reward results online.
    '''
    episode_rewards = []
    for i in range(max_episodes):
        episode_rewards.append(run_episode(mdp, agent, kbd_ctl=False))
        if i % 1 == 0:
            agent.epsilon *= epsilon_decay

        if plot:
            plt.interactive(True)
            plt.clf()
            plt.ylabel('Reward per episodes')
            plt.xlabel('Episodes')
            plt.plot(episode_rewards)
            plt.draw()

        print "[episode %d] episode reward: %f.  Epsilon now: %f" %\
            (i, episode_rewards[-1], agent.epsilon)

    return episode_rewards
开发者ID:jscholz,项目名称:rl_tutorial,代码行数:28,代码来源:experiments.py


示例12: main

def main(argv=None):

    # Permit interactive use
    if argv is None:
        argv = sys.argv

    # Parse and check incoming command line arguments
    outsuffix = None
    try:
        try:
            opts, args = getopt.getopt(argv[1:], "h", ["help"])
        except getopt.error as msg:
            raise Usage(msg)
        for o, a in opts:
            if o in ("-h", "--help"):
                print(__doc__)
                return 0
            elif o == "-o":
                outsuffix = a
    except Usage as err:
        print(err.msg, file=sys.stderr)
        return 2

    # Push interactive mode off (in case we get used from IPython)
    was_interactive = plt.isinteractive()
    plt.interactive(False)

    # If not saving, then display.
    if not outsuffix:
        plt.show()

    # Pop interactive mode
    plt.interactive(was_interactive)
开发者ID:RhysU,项目名称:suzerain,代码行数:33,代码来源:perfect.py


示例13: __init__

    def __init__(self, client_pars=None, plot_template=None, interactive=True, **kwargs):
        self.client=Client(client_pars)
        self.connect()
        # initialize data containers
        self.pr=u.Param()
        self.ob=u.Param()
        self.err=[]
        self.ferr=None
        # initialize the plotter
        from matplotlib import pyplot
        self.interactive = interactive
        self.pp = pyplot
        pyplot.interactive(interactive)
        
        #self.template_default = default_template
        self.templates = templates
        #self.template = u.Param()
        self.p = u.Param(DEFAULT)
        #self.update_plot_layout(plot_template=plot_template)

        # save as 'cmd': tuple(ticket,buffer,key)
        # will call get cmds with 'cmd', save the ticket in <ticket> and
        # save the resulting data in buffer[key]
        
        self.cmd_dct = {}
        self.server_dcts={}
开发者ID:aglowacki,项目名称:ptypy,代码行数:26,代码来源:plot_client_20140517.py


示例14: generate_single_funnel_test_data

def generate_single_funnel_test_data( excitation_angles, emission_angles, \
                                          md_ex=0, md_fu=1, \
                                          phase_ex=0, phase_fu=0, \
                                          gr=1.0, et=1.0 ):

    ex, em = np.meshgrid( excitation_angles, emission_angles )

    alpha = 0.5 * np.arccos( .5*(((gr+2)*md_ex)-gr) )

    ph_ii_minus = phase_ex - alpha
    ph_ii_plus  = phase_ex + alpha
    
    print ph_ii_minus
    print ph_ii_plus

    Fnoet  =    np.cos( ex-ph_ii_minus )**2 * np.cos( em-ph_ii_minus )**2
    Fnoet += gr*np.cos( ex-phase_ex )**2    * np.cos( em-phase_ex )**2
    Fnoet +=    np.cos( ex-ph_ii_plus )**2  * np.cos( em-ph_ii_plus )**2
        
    Fnoet /= (2+gr)
    
    Fet   = .25 * (1+md_ex*np.cos(2*(ex-phase_ex))) \
        * (1+md_fu*np.cos(2*(em-phase_fu-phase_ex)))
    
    
    Fem = et*Fet + (1-et)*Fnoet


    import matplotlib.pyplot as plt
    plt.interactive(True)
    plt.matshow( Fem, origin='bottom' )
    plt.colorbar()
开发者ID:kiwimatto,项目名称:2dpolim-analysis,代码行数:32,代码来源:util_misc.py


示例15: interactive

def interactive(b):
    b_prev = plt.isinteractive()
    plt.interactive(b)
    try:
        yield
    finally:
        plt.interactive(b_prev)
开发者ID:ronniemaor,项目名称:timefit,代码行数:7,代码来源:misc.py


示例16: createHistogramOfOrientedGradientFeatures

def createHistogramOfOrientedGradientFeatures(sourceImage, numOrientations, pixelsPerCell):
    # Returns an nxd matrix, n pixels and d the HOG vector length.
    
    # H is a matrix NBLOCKS_Y x NBLOCKS_X x CPB_Y x CPB_X x ORIENTATIONS
    # Here CPB == 1
    H,Himg = myhog.hog( sourceImage, numOrientations, pixelsPerCell, cells_per_block=(1,1), flatten=False, visualise=True )
    hog_image_rescaled = skimage.exposure.rescale_intensity( Himg )#, in_range=(0, 0.2))
    plt.interactive(True)
    plt.figure()
    plt.subplot(1,2,1)
    plt.imshow(sourceImage)
    plt.subplot(1,2,2)
    plt.imshow( hog_image_rescaled, cmap=plt.cm.gray )
    plt.title('HOG')
    plt.waitforbuttonpress()

    # Reduce to non-singleton dimensions, BY x BX x ORIENT
    H = H.squeeze()
    assert H.ndim == 3
    assert H.max() <= 1.0
    # resize to image pixels rather than grid blocks
    hogImg = np.zeros( ( sourceImage.shape[0], sourceImage.shape[1], numOrientations ), dtype=float )
    for o in range(numOrientations):
        hogPerOrient = H[:,:,o].astype(np.float32)
        hpoAsPil = pil.fromarray( hogPerOrient, mode='F' )
        hogImg[:,:,o] = np.array( hpoAsPil.resize( (sourceImage.shape[1], sourceImage.shape[0]), pil.NEAREST ) )
    return hogImg.reshape( ( sourceImage.shape[0]*sourceImage.shape[1], numOrientations ) )
开发者ID:RockStarCoders,项目名称:alienMarkovNetworks,代码行数:27,代码来源:FeatureGenerator.py


示例17: plot_patches

def plot_patches(patches, fignum=None, low=0, high=0):
    """
    Given a stack of 2D patches indexed by the first dimension, plot the
    patches in subplots.

    'low' and 'high' are optional arguments to control which patches
    actually get plotted. 'fignum' chooses the figure to plot in.
    """
    try:
        istate = plt.isinteractive()
        plt.ioff()
        if fignum is None:
            fig = plt.gcf()
        else:
            fig = plt.figure(fignum)
        if high == 0:
            high = len(patches)
        pmin, pmax = patches.min(), patches.max()
        dims = np.ceil(np.sqrt(high - low))
        for idx in xrange(high - low):
            spl = plt.subplot(dims, dims, idx + 1)
            ax = plt.axis('off')
            im = plt.imshow(patches[idx], cmap=matplotlib.cm.gray)
            cl = plt.clim(pmin, pmax)
        plt.show()
    finally:
        plt.interactive(istate)
开发者ID:fred1234,项目名称:BigData,代码行数:27,代码来源:patches.py


示例18: show_result

def show_result(lr, title):
    fig, axarr = plt.subplots(2, 1)
    fig.suptitle(title, fontsize=16)

    # Draw line
    num_samples = 1000
    x = lr.features[:, :-1]
    min_val_x, max_val_x = np.floor(np.amin(x)), np.ceil(np.amax(x))
    x_continue = np.linspace(min_val_x, max_val_x, num_samples).reshape(num_samples, 1)
    features = np.hstack((x_continue, np.ones((num_samples, 1))))
    y_continue = lr.hypothesise(features)
    axarr[0].set_title("Draw line.")
    axarr[0].plot(lr.features[:, :-1], lr.labels, 'bo')
    axarr[0].plot(x_continue, y_continue, 'r-')
    axarr[0].axis([min_val_x, max_val_x, np.amin(y_continue), np.amax(y_continue)])

    # History of the Cost
    num_iters = len(lr.loss_history)
    axarr[1].set_title("History of the Cost")
    axarr[1].plot(np.linspace(1, num_iters, num_iters), lr.loss_history, 'b-')
    axarr[1].axis([0, num_iters, 0, np.max(lr.loss_history)])

    plt.interactive(False)
    plt.show(block=True)
    plt.show()
开发者ID:NoNeil,项目名称:MachineLearningInPython,代码行数:25,代码来源:LinearRegressionImpl.py


示例19: __init__

 def __init__(self, i):
     #TO-DO: work the i argument
     plt.interactive(True)
     self._figure = plt.figure()
     
     ax = f.add_subplot()   #<- TO-DO: depending on intended axes and geometries
     
     '''
开发者ID:asrbrr,项目名称:datacleaning,代码行数:8,代码来源:plots.py


示例20: main

def main():
    plt.interactive(False)
    #analyseSimpleBatchGradientDescent()
    #analyseSimpleBatchGradientDescentRegularization()
    #analyseSimpleBatchGradientDescentMNIST()
    analyseBatchVersusMiniBatch()
    #analyseOneVersusAll()
    return
开发者ID:JonasSejr,项目名称:MLAU,代码行数:8,代码来源:logisticregression.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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