Exemplo n.º 1
0
def _plotBorder(nc, map, color='blue'):
    Nx, Ny, _Nz, longitude, latitude, _dx, _dy, _x, _y = getDimensions(nc)
    x, y = map(longitude, latitude)
    plt.plot(x[0, :], y[0, :], color, lw=2)
    plt.plot(x[:, 0], y[:, 0], color, lw=2)
    plt.plot(x[Ny - 1, :], y[Ny - 1, :], color, lw=2)
    plt.plot(x[:, Nx - 1], y[:, Nx - 1], color, lw=2)
Exemplo n.º 2
0
def _plotBorder(nc, map, color="blue"):
    Nx, Ny, _Nz, longitude, latitude, _dx, _dy, _x, _y = getDimensions(nc)
    x, y = map(longitude, latitude)
    plt.plot(x[0, :], y[0, :], color, lw=2)
    plt.plot(x[:, 0], y[:, 0], color, lw=2)
    plt.plot(x[Ny - 1, :], y[Ny - 1, :], color, lw=2)
    plt.plot(x[:, Nx - 1], y[:, Nx - 1], color, lw=2)
Exemplo n.º 3
0
def xzCloudPlot(nest,time,plotTemp=True,plotRH=False):
    nc = openWRF(nest)
    Nx,Ny,Nz,longitude,_lats,_dx,_dy,x_nr,y_nr = getDimensions(nc)
    
    heightground_x,heighthalf_xz = _getHeight(nc, time, Nx, -1, Nz, -1, y_nr)    
    print 'Model height: ' + str(heightground_x[x_nr])

    theta = nc.variables['T'][time,:,y_nr,:] + T_base 
    P = nc.variables['P'][time,:,y_nr,:] + nc.variables['PB'][time,:,y_nr,:] 
    T = theta*(P/P_bot)**kappa # Temperatur i halvflatene (Kelvin)
    rho = P/(R*T) #[kg/m3]

    qcloud_xz = 1000.0*nc.variables['QCLOUD'][time,:,y_nr,:]*rho # regner om til g/m3
    qrain_xz = 1000.0*nc.variables['QRAIN'][time,:,y_nr,:]*rho 
    qsnow_xz = 1000.0*nc.variables['QSNOW'][time,:,y_nr,:]*rho 
   
    plt.figure()
    plt.set_cmap(cmap_red)
    plt.axis([0,Nx-1,0.0,z_max])
    print u'Cloud water red, snow blue, rain green ($g/m^3$)'
    grid = np.reshape(np.tile(arange(Nx),Nz),(Nz,-1))
    plt.contourf(grid, heighthalf_xz, qcloud_xz, alpha=0.9,levels=xz_cloudwater_levels, cmap=cmap_red)#
    plt.colorbar()
    plt.contourf(grid, heighthalf_xz, qrain_xz, alpha=0.6,levels=xz_rain_levels, cmap=cmap_green)#
    plt.colorbar()
    plt.contourf(grid, heighthalf_xz, qsnow_xz, alpha=0.6,levels=xz_snow_levels,cmap=cmap_blue)# 
    plt.colorbar()

    if plotTemp:
        temp_int = arange(-80.0,50.0,2.0)
        cs = plt.contour(grid, heighthalf_xz, T-T_zero, temp_int,colors='black',linestyles='solid')#linewidths=4
        plt.clabel(cs, inline=1,  fmt='%1.0f', fontsize=12,colors='black')
    if plotRH:
        rh = _getRH(nc,time,-1,y_nr,T,P)
        rh_int = arange(90.,111.,5.)
        cs = plt.contour(grid, heighthalf_xz,rh , rh_int, colors='grey')
        plt.clabel(cs, inline=1,  fmt='%1.0f', fontsize=12, colors='grey')
    plt.plot(arange(Nx),heightground_x,color='black')
    plt.fill_between(arange(Nx),heightground_x,0,facecolor='lightgrey')
    plt.xticks(np.arange(0,Nx,8),np.round(longitude[Ny/2,::8], 1), fontsize='small')
    plt.yticks(np.arange(0,z_max,dz), fontsize='small')
    plt.xlabel('Lengdegrad')
    plt.ylabel(u'Høyde [m]')
    plt.show()
    plt.close()        
    train_generator,
    steps_per_epoch = train_generator.samples // batch_size,
    validation_data = validation_generator, 
    validation_steps = validation_generator.samples // batch_size,
    epochs = num_epochs)

View the Loss History

We tracked average training and validation loss for each epoch. We can plot these to see where the levels of loss converged, and to detect overfitting (which is indicated by a continued drop in training loss after validation loss has levelled out or started to increase.

from matplotlib import pyplot as plt

epoch_nums = range(1,num_epochs+1)
training_loss = history.history["loss"]
validation_loss = history.history["val_loss"]
plt.plot(epoch_nums, training_loss)
plt.plot(epoch_nums, validation_loss)
plt.xlabel('epoch')
plt.ylabel('loss')
plt.legend(['training', 'validation'], loc='upper right')
plt.show()


'''
Using the Trained Model

Now that we've trained the model, we can use it to predict the class of an image.
'''

def predict_image(classifier, image_array):
    import numpy as np
Exemplo n.º 5
0
def from_file_radius_gyr3(file_name, subpref):
    
    users_list = rd.read_in_subpref_users(subpref)
    
    total = float(rd.read_in_subpref_num_users()[subpref])
    
    if total > 0:
    
        nits = []
        its = []
        
        # a loop where we populate those two arrays from the file
        i = 0
        f = open(file_name, 'r')    
        # read the file
        for line in f:
            i = i + 1
            it, nit = line.split('\t')
            nit = float(nit)
            it = int(it)
            if users_list[it] == 1:
                nit = int(nit)
                nits.append(nit)
                its.append(it)
    
        mi = min(nits)
        mx = max(nits)
        print("Minimum radius of gyr ", mi)
        print("Maximum radius of gyr ", mx)
        
        total_nit = float(sum(nits))
        print("Total radius of gyr ", total_nit)
        
        pdf_nits = defaultdict(int)
        
        for j in range(0, len(nits)):
            pdf_nits[nits[j]] += 1
            
        ordered = OrderedDict(sorted(pdf_nits.items(), key=lambda t: t[0]))
        
        nits7s = []
        its7s = []
        
        test = 0
        #total = 500000.0
        
        for j in ordered.iterkeys():
            nits7s.append(ordered[j]/total)
            test += ordered[j]/total
            its7s.append(j)
            
        print test
            
    ############################################################################################################################
    # THIS is to plot number of users pdf
    ############################################################################################################################
    
        plt.figure(7)
    
        plt.plot(its7s, nits7s, 'o', linewidth=0.5, label= 'distribution of Rg')
        
        plt.xlabel('rg [km]')
        plt.ylabel('P(rg)')
        plt.legend()   
        
        # this is if we want loglog lot, otheriwse comment and uncomment next line for regular plot file   
        plt.yscale('log')
        plt.xscale('log')
        figure_name = "/home/sscepano/D4D res/allstuff/rg/1/rg_" + str(subpref) + ".png"
              
        print(figure_name)
        plt.savefig(figure_name, format = "png", dpi=300)      
        
        plt.clf()
    
    return
# load the dataset
import pyplot as plt
data = read_csv('brain activity.txt', header=None)
# retrieve data as numpy array
values = data.values
# create a subplot for each time series
plt.figure()
for i in range(values.shape[1]):
	plt.subplot(values.shape[1], 1, i+1)
	plt.plot(values[:, i])
plt.show()
Exemplo n.º 7
0
import sys
sys.path.append('/usr/local/anaconda3/lib/python3.6/site-packages')
from numpy import *
x = linspace(0, 7, 70)
y = sin(x)
f1 = x
s = (

from matplotlib import pyplot as plt
plt.grid
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title('Funkcija $sin(x)$')
plt.plot(x, y2, color = "#7FFF00")
plt.show()



Exemplo n.º 8
0
som.random_weights_init(X)
som.train_random(data=X, num_iteration=100)

# Visualizing the results
from pyplot import bone, pcolor, colorbar, plot, show
bone()
pcolor(som.distance_map().T)
colorbar()
marker = ['o', 's']
color = ['r', 'g']
for i, x in enumerate(X):
    w = som.winner(X)
    plot(w[0] + 0.5,
         w[1] + 0.5,
         markers[y[i]],
         markeredgecolor=colors[y[i]],
         markerfacecolor=None,
         markersize=10,
         markeredgewidth=2)

show()

#Finding the fraud
mappings = som.win_map(X)
frauds = np.concatenate((mappings[(8, 1)], mappings[(6, 8)]), axis=0)
frauds = sc.inverse_transform(frauds)

#part- 2 Going from Unsupervised to supervised  Deep Learning
#Creating the matrix of feature
customer = dataset.iloc[:, 1:].values
#Creating the dependent variable
Exemplo n.º 9
0
import scikits.audiolab as audio
import pyplot as plt
from scipy.fftpack import fft, fftfreq
#%pylab inline

input_signal, sampling_rate, enc = audio.wavread("minombre.wav")

fft_mivoz = fft(input_signal) / len(input_signal)
frecuencia = fftfreq(len(input_signal), 1)
plt.plot(frecuencia, fft_mivoz)

save("mivoz_fft", ext="png", close=False, verbose=True)
Exemplo n.º 10
0
def save_to_plot(avg_usr_traj):
    
    nits = []
    its = []
    
    # a loop where we populate those two arrays from the file
    i = 0
#    f = open(file_name, 'r')    
#    # read the file
    for usr in range(500001):
        i = i + 1
        nits.append(int(avg_usr_traj[usr]))
        its.append(usr)

    mi = min(nits)
    mx = max(nits)
    print("Minimum radius of gyr ", mi)
    print("Maximum radius of gyr ", mx)
    
    total_nit = float(sum(nits))
    print("Total radius of gyr ", total_nit)
    
    pdf_nits = defaultdict(int)
    
    for j in range(0, len(nits)):
        pdf_nits[nits[j]] += 1
        
    ordered = OrderedDict(sorted(pdf_nits.items(), key=lambda t: t[0]))
    
    nits7s = []
    its7s = []
    
    test = 0
    
    for j in ordered.iterkeys():
        nits7s.append(ordered[j]/500000.0)
        test += ordered[j]/500000.0
        its7s.append(j)
        
    print test
        
############################################################################################################################
# THIS is to plot number of users pdf
############################################################################################################################

    plt.figure(7)

    plt.plot(its7s, nits7s, 'o', linewidth=0.5, label= 'distribution of Rg')
    
    plt.xlabel('rg [km]')
    plt.ylabel('P(rg)')
    plt.legend()   
    
    # this is if we want loglog lot, otheriwse comment and uncomment next line for regular plot file   
    plt.yscale('log')
    plt.xscale('log')
    figure_name = "/home/sscepano/D4D res/allstuff/traj/avg daily/avg_daily_traj_total.png"
          
    print(figure_name)
    plt.savefig(figure_name, format = "png", dpi=300)    
    
    return
Exemplo n.º 11
0
def get_ROI_4_sides(ax = None):
    """
    Returns four sides of an Region Of Interest
    """
    # Assumes scale bar length 500 microns
    scalebar_len_um = 500. # microns
    #prestm_col = [.3,.7,.3]

    # If no axes was set, plot on the currently active.
    if ax is None:
        ax = plt.gca()
        
    print 'Click on the top and the bottom of the scalebar.\n'
    sclbar_xy_px = np.array(plt.ginput(n=2))
    
    print 'Click on pipette tip/cell.\n'
    cell_xy_px = np.array(plt.ginput(n=1, timeout=60))[0]
    
    sclbar_len_px = abs(diff(sclbar_xy_px[:,1]))[0]
    um_to_px = sclbar_len_px/scalebar_len_um
    
    xlim_px, ylim_px = ax.get_xlim(), ax.get_ylim()
    xlim_um = ((xlim_px[0]-cell_xy_px[0])/um_to_px,
               (xlim_px[1]-cell_xy_px[0])/um_to_px)
    ylim_um = ((ylim_px[0]-cell_xy_px[1])/um_to_px,
               (ylim_px[1]-cell_xy_px[1])/um_to_px)
    IM = ax.get_images()[0]
    IM.set_extent((xlim_um[0], xlim_um[1], ylim_um[0], ylim_um[1]))
    xlabel('micron')
    ylabel('micron')
    plt.draw()
    sleep(1e-3)
    
    # Get and plot the outer borders of the area to stimulate
    print 'Click on 4 corners making up the border of region to stimulate.\n'
    region_border_xy = np.array(ginput(n=4))
    lol_bix = np.ones(4, dtype=bool)
    up_ix = np.argsort(region_border_xy[:,1])[2:]
    r_ix = np.argsort(region_border_xy[:,0])[2:]
    lol_bix[up_ix] = False
    lor_bix = lol_bix.copy()
    lol_bix[r_ix] = False
    lor_bix[lol_bix] = False  
    upl_bix = ~(lor_bix | lol_bix)
    upl_bix[r_ix] = False
    upr_bix = ~(lor_bix | lol_bix | upl_bix)
    lo_left = region_border_xy[lol_bix, :].flatten()
    up_right = region_border_xy[upr_bix, :].flatten()
    lo_right = region_border_xy[lor_bix, :].flatten()
    up_left = region_border_xy[upl_bix, :].flatten()
        
    plt.plot([lo_left[0], up_left[0], up_right[0], lo_right[0], lo_left[0]], 
             [lo_left[1], up_left[1], up_right[1], lo_right[1], lo_left[1]],
             c=prestm_col)

    ax.set_xlim(xlim_um)
    ax.set_ylim(ylim_um)
    corners = {'lo_left':lo_left,
               'up_left':up_left,
               'up_right':up_right,
               'lo_right':lo_right}          

    return corners
Exemplo n.º 12
0
def yzCloudPlot(nest, time, plotTemp=True, plotRH=False):
    nc = openWRF(nest)
    Nx, Ny, Nz, _longs, latitude, _dx, _dy, x_nr, y_nr = getDimensions(nc)

    heightground_y, heighthalf_yz = _getHeight(nc, time, -1, Ny, Nz, x_nr, -1)
    print 'Model height: ' + str(heightground_y[y_nr])

    theta = nc.variables['T'][time, :, :, x_nr] + T_base
    P = nc.variables['P'][time, :, :, x_nr] + nc.variables['PB'][time, :, :,
                                                                 x_nr]
    T = theta * (P / P_bot)**kappa  # Temperatur i halvflatene (Kelvin)
    rho = P / (R * T)  #[kg/m3]

    qcloud_yz = 1000.0 * nc.variables['QCLOUD'][
        time, :, :, x_nr] * rho  # regner om til g/m3
    qrain_yz = 1000.0 * nc.variables['QRAIN'][time, :, :, x_nr] * rho
    qsnow_yz = 1000.0 * nc.variables['QSNOW'][time, :, :, x_nr] * rho

    plt.figure()
    plt.set_cmap(cmap_red)
    plt.axis([0, Ny - 1, 0.0, z_max])
    print u'Cloud water red, snow blue, rain green ($g/m^3$)'
    grid = np.reshape(np.tile(arange(Ny), Nz), (Nz, -1))
    plt.contourf(grid,
                 heighthalf_yz,
                 qcloud_yz,
                 alpha=0.9,
                 levels=xz_cloudwater_levels,
                 cmap=cmap_red)  #
    plt.colorbar()
    plt.contourf(grid,
                 heighthalf_yz,
                 qrain_yz,
                 alpha=0.6,
                 levels=xz_rain_levels,
                 cmap=cmap_green)  #
    plt.colorbar()
    plt.contourf(grid,
                 heighthalf_yz,
                 qsnow_yz,
                 alpha=0.6,
                 levels=xz_snow_levels,
                 cmap=cmap_blue)  #
    plt.colorbar()

    if plotTemp:
        cs = plt.contour(grid,
                         heighthalf_yz,
                         T - T_zero,
                         temp_int,
                         colors='black',
                         linestyles='solid')  #linewidths=4
        plt.clabel(cs, inline=1, fmt='%1.0f', fontsize=12, colors='black')
    if plotRH:
        rh = _getRH(nc, time, x_nr, -1, T, P)
        rh_int = arange(90., 111., 5.)
        cs = plt.contour(grid, heighthalf_yz, rh, rh_int, colors='grey')
        plt.clabel(cs, inline=1, fmt='%1.0f', fontsize=12, colors='grey')
    plt.plot(arange(Ny), heightground_y, color='black')
    plt.fill_between(arange(Ny), heightground_y, 0, facecolor='lightgrey')
    plt.xticks(np.arange(0, Ny, 8),
               np.round(latitude[::8, Nx / 2], 1),
               fontsize='small')
    plt.yticks(np.arange(0, z_max, dz), fontsize='small')
    plt.xlabel('Breddegrad')
    plt.ylabel(u'Høyde [m]')
    plt.show()
    plt.close()
Exemplo n.º 13
0
def _makeDots(m):
    x_f, y_f = m(lon_focuspoint, lat_focuspoint)
    plt.plot(x_f, y_f, 'ro')
    if (lon_rg != -1 and lat_rg != -1):
        x_rg, y_rg = m(lon_rg, lat_rg)
        plt.plot(x_rg, y_rg, 'ro')
Exemplo n.º 14
0
def from_files_usr_movements():

    file_name1 = "/home/sscepano/D4D res/allstuff/USER GRAPHS stats/user_number_of_edges_v1.tsv"
    file_name2 = "/home/sscepano/D4D res/allstuff/USER GRAPHS stats/user_number_of_nodes_v1.tsv"
    file_name3 = "/home/sscepano/D4D res/allstuff/USER GRAPHS stats/user_number_of_displacements_v1.tsv"

    nits = []
    its = []

    # a loop where we populate those two arrays from the file
    i = 0
    f = open(file_name3, "r")
    # read the file
    for line in f:
        i = i + 1
        it, nit = line.split("\t")
        nit = int(nit)
        it = int(it)
        nit = int(nit)
        nits.append(nit)
        its.append(it)

    mi = min(nits)
    mx = max(nits)
    print ("Minimum # edges ", mi)
    print ("Maximum # edges ", mx)

    total_nit = float(sum(nits))
    print ("Total # edges ", total_nit)

    pdf_nits = defaultdict(int)

    for j in range(0, len(nits)):
        pdf_nits[nits[j]] += 1

    ordered = OrderedDict(sorted(pdf_nits.items(), key=lambda t: t[0]))

    nits7s = []
    its7s = []

    test = 0

    for j in ordered.iterkeys():
        nits7s.append(ordered[j] / 500000.0)
        test += ordered[j] / 500000.0
        its7s.append(j)

    print test

    ############################################################################################################################
    # THIS is to plot number of users pdf
    ############################################################################################################################

    plt.figure(7)

    plt.plot(its7s, nits7s, "o", linewidth=0.5, label="distr. of # displacements ")

    plt.xlabel("# displacements")
    plt.ylabel("P(# displacements)")
    plt.legend()

    # this is if we want loglog lot, otheriwse comment and uncomment next line for regular plot file
    plt.yscale("log")
    plt.xscale("log")
    # figure_name1 = "/home/sscepano/D4D res/allstuff/USER GRAPHS stats/usr_num_edges.png"
    # figure_name2 = "/home/sscepano/D4D res/allstuff/USER GRAPHS stats/usr_num_nodes.png"
    figure_name3 = "/home/sscepano/D4D res/allstuff/USER GRAPHS stats/usr_num_displacements.png"

    print (figure_name3)
    plt.savefig(figure_name3, format="png", dpi=300)

    return
Exemplo n.º 15
0
# coding: utf-8
import numerical1 as num
from defns import *
def anal(t, g):
    x=np.exp(-g/2. t)*np.cos(np.sqrt(4-g**2)/2. t)
    p=np.exp(-g/2. t)*np.sin(np.sqrt(4-g**2)/2. t)
    return x,p
def anal(t, g):
    x=np.exp(-g/2.*t)*np.cos(np.sqrt(4-g**2)/2.*t)
    p=np.exp(-g/2.*t)*np.sin(np.sqrt(4-g**2)/2.*t)
    return x,p
get_ipython().set_next_input(u't=np.arange');get_ipython().magic(u'pinfo np.arange')
t=np.arange(0., 100., 0.5)
x,p=anl(t, g) 
x,p=anal(t, g)
x
import pyplot as plt
import matplotlib.pyplot as plt
plt.figure()
plt.plot(t, x, t, p)
plt.show()
get_ipython().magic(u'save "commands.py"')
Exemplo n.º 16
0
def _makeDots(m):
    x_f, y_f = m(lon_focuspoint, lat_focuspoint)
    plt.plot(x_f, y_f, "ro")
    if lon_rg != -1 and lat_rg != -1:
        x_rg, y_rg = m(lon_rg, lat_rg)
        plt.plot(x_rg, y_rg, "ro")
Exemplo n.º 17
0
import numpy as np
import pyplot as pl
from scipy import interpolate
from scipy import integrate

file = np.loadtxt('podaci.txt')
L = file[:,0]
I = file[:,1]

spl = interpolate.splrep(L,I,k=3)
Lk = file[:,0]
Ik = spl(xs)
pl.plot(xs, ys)
pl.show()
Exemplo n.º 18
0
def from_file_num_calls(file_name): 
   
    # here we store the num of calls made by a user
    usr_and_his_num_calls = n.zeros(500001, dtype=n.int)
    # here we store the fq of calls made by a user, but we calculate it from the num_calls
    fq_distr = n.zeros(max_num_calls)
    # from the previous array obtained by counting users who made the same total number of calls
    nc_distr = n.zeros(max_num_calls, dtype=n.int)
    # here we just save percents of users
    nc_distr_pct = n.zeros(max_num_calls)
    
    
    # a loop where we populate those two arrays from the file
    i = 0
    f = open(file_name, 'r')    
    # read the file
    for line in f:
        i = i + 1
        u, nc = line.split('\t')
        nc = int(nc)
        u = int(u)
        usr_and_his_num_calls[u] = nc
        nc_distr[nc] += 1

    mi = min(usr_and_his_num_calls)
    mx = max(usr_and_his_num_calls)
    print("Minimum number of calls ", mi)
    print("Maximum number of calls ", mx)
    
    total_u = float(sum(nc_distr))
    print("Total users found ", total_u)
    
#   test_file_out = "/home/sscepano/D4D res/allstuff/SET3 frequent callers from python/1/Obtained_num_calls_and_its_pct.tsv"
#   fto =  open(test_file_out,"w")
    for j in range(0, max_num_calls):
        nc_distr_pct[j] = (nc_distr[j] / total_u)
#        fto.write(str(j) + '\t' + str(nc_distr_pct[j]) + '\n')

#    # I was just checking that the total percents sums up to 100 and they do but it looked funny as we have so small values
#    total = 0    
#    for i in range (max_num_calls):
#        total += percent_users[i]
#    print ("Check ", total)

############################################################################################################################
# THIS is to plot number of users pdf
############################################################################################################################

    plt.figure(1)

    plt.plot(nc_distr_pct, 'r', linewidth=0.5, label= 'distribution of N')
    
    plt.xlabel('N, num of calls')
    plt.ylabel('% Users')
    plt.legend()   
    
#    # this is if we want loglog lot, otheriwse comment and uncomment next line for regular plot file   
    plt.yscale('log')
    plt.xscale('log')
#    figure_name = "/home/sscepano/D4D res/allstuff/SET3 frequent callers from python/1/SET3 distr of num of calls loglog.png" 
    
    #this is a regular plot file, then comment the previous loglog block
    figure_name = "/home/sscepano/D4D res/allstuff/SET3 frequent callers from python/1/distr of num of calls2.png"
      
    print(figure_name)
    plt.savefig(figure_name, format = "png", pdi=300) 
    #plt.show()       
    
###############################################################################################################################
# THIS is to plot fq pdf
###############################################################################################################################

    plt.figure(2)
    
#    fq = []
#    
#    for j in range(max_num_calls):
#        fq.append( float(j / 3360.0))
#
#    ffq = []
#    
#    for j in range(max_num_calls):
#        ffq.append(nc_distr_pct[j])

#    for j in range(0, max_num_calls):
#        nc_distr_pct[j] = (nc_distr[j] / total_u)

    fq = []
    
    for j in range(max_num_calls):
        fq.append( float(j / 3360.0))

    ffq = []
    
    for j in range(max_num_calls):
        ffq.append(nc_distr_pct[j])
        
   
#    test_file_out2 = "/home/sscepano/D4D res/allstuff/SET3 frequent callers from python/1/Calculated_fq_calls_and_its_pct2.tsv"
#    fto2 =  open(test_file_out2,"w")
#    for j in range(0, max_num_calls):
#        fto2.write(str(fq[j]) + '\t' + str(ffq[j]) + '\n')    


    # Finally understood here -- when I give two arrays: x, y (at least append values IN ORDER like here) -- pyplot will plot y versus x
    plt.plot(fq, ffq, 'g', linewidth=0.3, label= 'distribution of Fq')
    
    plt.xlabel('Fq of calls')
    plt.ylabel('% Users')
    plt.legend()   
    
    # this is if we want loglog lot, otheriwse comment and uncomment next line for regular plot file   
    plt.yscale('log')
    plt.xscale('log')
    figure_name = "/home/sscepano/D4D res/allstuff/SET3 frequent callers from python/1/distr of fq of calls2.png" 
    
#    # this is a regular plot file, then comment the previous loglog block
#    figure_name = "/home/sscepano/D4D res/allstuff/SET3 frequent callers from python/1/SET3 distr of fq of calls.png"
      
    print(figure_name)
    plt.savefig(figure_name, format = "png")   
    

    return   
Exemplo n.º 19
0
def _isobars():
    for n in np.arange(P_bot, P_t - 1, -10**4):
        plt.plot([-40, 50], [n, n], color='black', linewidth=.5)
Exemplo n.º 20
0
def _isobars():
    for n in np.arange(P_bot,P_t-1,-10**4):
        plt.plot([-40,50], [n,n], color = 'black', linewidth = .5)
Exemplo n.º 21
0
math = np.array([85, 45, 80, 99, 45, 75])

from sklearn.linear_model import LinearRegression  #scikit-learn(sklearn)에 선형회귀 라이브러리가 포함되어 있어서 사용한다.

line_fitter = LinearRegression()

# fit()함수의 기능
# line_fitter.coef_ : 기울기를 저장한다. (coef : 기울기)
# line_fitter.intercept_ : 절편을 저장 (intercept : 절편)

line_fitter.fit(height, math)  #height와 math관의 상관관계를 구한다.

score_predict = line_fitter.predict(
    height)  ##height와 math관의 상관관계를 구하는 선형회귀선을 그린다. (score_predict : 점수 예측)

plt.plot(height, math, 'x')  #x는 height에 따른 math이다. (그래프에 나타내는 표시를 x로 한다.)
plt.plot(height, score_predict)
plt.show()  #데이터들을 나타낸 선형회귀선과 height에 따른 math을 나타내는 x를 출력한다.

#위에서 구현한 그래프에 기울기와 절편을 표현해보자.

line_fitter.coef_  #기울기 구하기

line_fitter.intercept_  #절편 구하기

#MSE를 이용해서 성능평가 진행 (성능평가를 위해서 mse를 import한다.)
from sklearn.metrics import mean_squared_error

print("Mean_Squared_Error(Mse) :", mean_squared_error(score_predict,
                                                      math))  #mse값을 구한다.
import scikits.audiolab as audio
import pyplot as plt
#%pylab inline

input_signal, sampling_rate, enc = audio.wavread("minombre.wav")
print (input_signal[0:10]), sampling_rate, enc

time_array = arange(0, len(input_signal)/float(sampling_rate), 1/float(sampling_rate))

plt.plot(time_array[0:4000], input_signal[0:4000])
plt.xlabel("time(s)", fontsize=20)
plt.ylabel("Amplitude", fontsize=20)

save("mi_voz", ext="png", close=False, verbose=True)
Exemplo n.º 23
0
def _makeDots(m):
    x_f,y_f = m(lon_focuspoint, lat_focuspoint)
    plt.plot(x_f,y_f,'ro')
    if (lon_rg != -1 and lat_rg != -1):
            x_rg, y_rg = m(lon_rg, lat_rg)
            plt.plot(x_rg,y_rg,'ro')
# Opmerking: voor gebruik van dit script met
#            visual code
#            set in settings: 
#            "python.pythonPath": "C:\\tmp\\cx1964ReposPlot\\env_python3_plot\\Scripts
#
#            indien mathplotlib nog niet geinstalleerd is run:
#            pip install mathplotlib
#
#            Nadat een grafiek wordt gelsoten wordt de volgende getoond.
#
import pyplot as plt

# Voorbeeld1: 1 grafieken in een afbeelding
x = [5,8,10]
y = [12,16,6]
plt.plot(x,y)
plt.title('Titel van de grafiek voorbeeld1')
plt.ylabel('Y-as')
plt.xlabel('X-as')
plt.show()


# Voorbeeld2: 2 grafieken in een afbeelding
#from matplotlib import pyplot as plt
from matplotlib import style
style.use('ggplot')
x1 = [0,1,2,3,4,5]
y1 = [0,1,4,9,16,25]
x2 = x1
y2 = [5,7,9,11,13,15]
# can plot specifically, after just showing the defaults:
Exemplo n.º 25
0
from matplotlib import pyplot
from pyplot import plot

x = []
y = []
for i in range(36):
    print i
    x.append[i]
    y.append[i+2]

plot(x, y)