How to use the matplotlib.pyplot.plot function in matplotlib

To help you get started, we’ve selected a few matplotlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GeoscienceAustralia / anuga_core / validation_tests / analytical_exact / subcritical_depth_expansion / plot_results.py View on Github external
#v2=(p2_st.y>-1.0)
v2 = arange(len(p2_st.y))

if verbose: print 'Calculate analytical solution'
h,z = analytic_sol(p2_st.x[v2])
qexact = 1.0




#Plot the stages##############################################################
if verbose: print 'Create Stage plot'
pyplot.clf()
pyplot.plot(p2_st.x[v2], p2_st.stage[tid,v2], 'b.-', label='numerical stage') # 0*T/6
pyplot.plot(p2_st.x[v2], h+z,'r-', label='analytical stage')
pyplot.plot(p2_st.x[v2], z,'k-', label='bed elevation')
pyplot.xlim((5,20))
pyplot.title('Stage at time = %s secs'% p2_st.time[tid])
##pyplot.ylim(-5.0,5.0)
pyplot.legend(loc='best')
pyplot.xlabel('Xposition')
pyplot.ylabel('Stage')
pyplot.savefig('stage_plot.png')


#Plot the momentums##########################################################
if verbose: print 'Create Momentum plot'
pyplot.clf()
pyplot.plot(p2_st.x[v2], p2_st.xmom[tid,v2], 'b.-', label='numerical') # 0*T/6
pyplot.plot(p2_st.x[v2], qexact*ones(len(p2_st.x[v2])),'r-', label='analytical')
pyplot.xlim((5,20))
pyplot.title('Xmomentum at time = %s secs'% p2_st.time[tid])
github damonge / CoLoRe / test_files / mk_files.py View on Github external
bzarr=np.ones_like(zarr)
bzarr2=2*np.ones_like(zarr)
tzarr=5.5919E-2+2.3242E-1*zarr-2.4136E-2*zarr**2.
norm=ngal/(4*np.pi*(180/np.pi)**2*np.sum(nzarr)*(zf-z0)/nz)
nzarr*=norm
norm2=ngal2/(4*np.pi*(180/np.pi)**2*np.sum(nzarr2)*(zf-z0)/nz)
nzarr2*=norm2

np.savetxt("Nz_test.txt",np.transpose([zarr,nzarr]))
np.savetxt("Nz2_test.txt",np.transpose([zarr,nzarr2]))
np.savetxt("Tz_test.txt",np.transpose([zarr,tzarr]))
np.savetxt("Bz_test.txt",np.transpose([zarr,bzarr]))
np.savetxt("Bz2_test.txt",np.transpose([zarr,bzarr2]))
np.savetxt("nuTable.txt",np.transpose([nu0_arr,nuf_arr]))

plt.plot(zarr,nzarr); plt.plot(zarr,nzarr2); plt.show()
plt.plot(zarr,bzarr); plt.show()
plt.plot(zarr,tzarr); plt.show()
github slinderman / pyglm / test / test_single_neuron_vb.py View on Github external
def test_gibbs_update_synapses():
    """
    Test the mean field updates for synapses
    """
    population = create_simple_population(N=5, T=10000)
    neuron = population.neuron_models[0]
    synapse = neuron.synapse_models[0]
    data = neuron.data_list[0]

    plt.ion()
    plt.figure()
    plt.plot(data.psi, '-b')
    plt.plot(np.nonzero(data.counts)[0], data.counts[data.counts>0], 'ko')
    psi = plt.plot(data.psi, '-r')
    plt.show()


    A_true = neuron.An.copy()
    print "A_true: ", neuron.An
    print "W_true: ", neuron.weights
    print "b_true: ", neuron.bias

    # Initialize to a random connections
    neuron.An = np.random.rand(5) < 0.5

    print "--" * 20

    raw_input("Press enter to continue...")

    N_iter = 1000
github prody / ProDy / prody / routines / routines.py View on Github external
prody.showContactMap(gnm)
                plt.savefig(os.path.join(outdir, prefix + '_cm.'+format), 
                    dpi=dpi, format=format)
                plt.close('all')
            if figall or sf:
                plt.figure(figsize=(width, height))
                prody.showSqFlucts(gnm)
                plt.savefig(os.path.join(outdir, prefix + '_sf.'+format), 
                    dpi=dpi, format=format)
                plt.close('all')
            if figall or bf:
                plt.figure(figsize=(width, height))
                bexp = select.getBetas()
                bcal = prody.calcTempFactors(gnm, select)
                plt.plot(bexp, label='Experimental')
                plt.plot(bcal, label=('Theoretical (corr coef = {0:.2f})'
                                        .format(np.corrcoef(bcal, bexp)[0,1])))
                plt.legend(prop={'size': 10})
                plt.xlabel('Node index')
                plt.ylabel('Experimental B-factors')
                plt.title(pdb.getTitle() + ' B-factors')
                plt.savefig(os.path.join(outdir, prefix + '_bf.'+format), 
                    dpi=dpi, format=format)
                plt.close('all')
            if modes: 
                indices = []
                items = modes.split()
                items = sum([item.split(',') for item in items], [])
                for item in items:
                    try:
                        item = item.split('-')
                        if len(item) == 1:
github Doraemonzzz / Learning-from-data / Chapter8 / 代码 / exercise 8.6.py View on Github external
e = Eout(w, b)
print(e)

####(c)
clf = Perceptron()
clf.fit(X, y)

w1 = clf.coef_[0]
b1 = clf.intercept_[0]

#作图
m1 = np.array([-1, 1])
n1 = - (b + w[0] * m1) / w[1]
plt.scatter(x1[y>0], x2[y>0], label="+")
plt.scatter(x1[y<0], x2[y<0], label="-")
plt.plot(m1, n1, 'r')
plt.legend()
plt.show()

#多次实验,做直方图
result = np.array([])
for i in range(2000):
    np.random.shuffle(X)
    y = np.sign(X[:,1])
    clf.fit(X, y)
    w1 = clf.coef_[0]
    b1 = clf.intercept_[0]
    result = np.append(result,Eout(w1,b1))
    
plt.hist(result, label="PLA")
plt.plot([e] * 400, range(400), 'r', label="SVM")
plt.legend()
github hbhzwj / GAD / misc / TimeVaryingSuperImpose.py View on Github external
def tran_flow_size_to_time_varying(f_name, out_f_name, transform,
        data_pic_name):
    """ tranform flow size in the flow record to be time_varying model
    """
    flows,  keys = RawParseData(f_name)
    zip_flows = zip(*flows)
    t_idx = keys.index('start_time')
    fs_idx = keys.index('flow_size')
    t = [float(vt) for vt in zip_flows[t_idx]]
    mint = min(t)
    nt = [v_ - mint for v_ in t]

    flow_size = [float(fs) for fs in zip_flows[fs_idx]]
    fig = plt.figure()
    ax1 = fig.add_subplot(211)
    plt.plot(nt, flow_size, axes=ax1)
    new_flow_size = transform(t, flow_size)
    zip_flows[fs_idx] = [str(fs) for fs in new_flow_size]
    ax2 = fig.add_subplot(212)
    plt.plot(nt, new_flow_size, axes=ax2)
    # plt.savefig('scene.pdf')
    plt.savefig(data_pic_name)
    # plt.show()

    flows = zip(*zip_flows)
    write_file(out_f_name, FS_FORMAT, flows, keys)
github thjashin / gp-infer-net / toy.py View on Github external
def plot_ground_truth(test_x, test_y_mean_, test_y_var_):
    plt.plot(test_x, test_y_mean_, c="k", linewidth=2)
    plt.plot(test_x, test_y_mean_ + 3. * np.sqrt(test_y_var_), '--',
             color="k", linewidth=2)
    plt.plot(test_x, test_y_mean_ - 3. * np.sqrt(test_y_var_), '--',
             color="k", linewidth=2)
github neuromethods / fokker-planck-based-spike-rate-models / adex_comparison / calculate_quantities_spectral.py View on Github external
linecolor = color_regular
            else:
                linecolor = color_diffusive
            
            ylim_real = [-0.6, 0.01]
            # remove pts outside of limit
            if l_j==1 or k < 8:
                plotinds_real = (lambda_all[k, plotinds, j].real >= ylim_real[0]) & (lambda_all[k, plotinds, j].real <= ylim_real[1]) 
            else:
                plotinds_real = lambda_all[k, plotinds, j].real >= -10000.
            
            # eigenval: real part
            plt.subplot(2, N_plotcols, subplotid, 
                        sharex=ax_real if subplotid > 1 else None, 
                        sharey=ax_real if subplotid > 1 else None)
            plt.plot(mu[plotinds][plotinds_real], lambda_all[k, plotinds, j].real[plotinds_real], color=linecolor)
            if l_j==0:
                if k==0:
                    plt.ylabel('$\mathrm{Re}\lambda_n$ [kHz]')
            if k==0:
                plt.title('$\sigma={0:.3}$ [mV/$\sqrt{{\mathrm{{ms}}}}$]'.format(sigma[j]))
                plt.ylim(ylim_real)
                plt.yticks([-0.6,0])
                plt.plot(mu[plotinds][plotinds_real], np.zeros_like(mu[plotinds])[plotinds_real], color='gray', lw=2)
                plt.xlim(xlim)
            
            # dots for relation with other fig                
            if k==0 and l_j==0:
                i = np.argmin(np.abs(mu-0.25))
                plt.plot(mu[i], lambda_all[k, i, j].real, '^b', ms=5)
            if k==0 and l_j==0:
                i = np.argmin(np.abs(mu-1.5))
github booya-at / OpenGlider / freecad / freecad_glider / tools / panel_method.py View on Github external
def find_zeros(x, y):
            sign = np.sign(y[0])
            i = 1
            while i < len(y):
                if sign != np.sign(y[i]):
                    return x[i-1] + (x[i-1] - x[i]) * y[i-1] / (y[i] - y[i-1])
                i += 1
                if i > len(x):
                    return


        phi = newton_krylov(minimize, np.ones_like(self.alpha)) 
        a_p = [find_zeros(vel(phi), phi), find_zeros(gz(), phi)]
        plt.plot(vel(phi), gz())
        plt.plot(vel(phi), phi)
        plt.plot(a_p[0], a_p[1], marker='o')
        plt.plot()
        plt.grid()
        plt.show()
github Rapid-Design-of-Systems-Laboratory / beluga / examples / Classic / BrysonDenham / plotresults.py View on Github external
plt.plot(sol_indirect.t, sol_indirect.y[:, 0], linestyle='-', color='b', label='indirect')
plt.plot([sol_indirect.t[0], sol_indirect.t[-1]], [sol_indirect.const[-1]]*2, linestyle='--', color='k')
plt.title('Position')
plt.xlabel('Time [s]')
plt.legend()
plt.grid(True)

plt.figure()
plt.plot(sol_indirect.t, sol_indirect.y[:, 1], linestyle='-', color='b', label='indirect')
plt.title('Velocity')
plt.xlabel('Time [s]')
plt.legend()
plt.grid(True)

plt.figure()
plt.plot(sol_indirect.t, sol_indirect.u, linestyle='-', color='b', label='indirect')
plt.title('Control')
plt.xlabel('Time [s]')
plt.legend()
plt.grid(True)

plt.figure()
plt.plot(sol_indirect.t, sol_indirect.dual[:, 0], linestyle='-', color='b', label='indirect')
plt.title('Position Costate')
plt.xlabel('Time [s]')
plt.legend()
plt.grid(True)

plt.figure()
plt.plot(sol_indirect.t, sol_indirect.dual[:, 1], linestyle='-', color='b', label='indirect')
plt.title('Velocity Costate')
plt.xlabel('Time [s]')