Пример #1
0
def plot_share_delay_histogram(packets):
    """
    Takes a list of PacketInfo tuples as input and plots the PDF of the intershare delay.
    """
    seq_num_to_ts = defaultdict(list)
    for p_i in packets:
        seq_num_to_ts[p_i.seq_num].append(p_i.timestamp)

    inter_share_delays = []
    for seq_num, ts in seq_num_to_ts.items():
        inter_share_delay = max(ts) - min(ts)
        inter_share_delays.append(inter_share_delay)
    
    plt.histogram(inter_share_delays, density=True)
    helpers.save_figure("share-delay-pdf.pdf")
Пример #2
0
 def hist(self):
     pylt.histogram(self.nums)
Пример #3
0
import numpy as np
import matplotlib.pyplot as plt

data = np.loadtxt('X.dat')

plt.figure()
plt.histogram(data)
plt.show()
Пример #4
0
import matplotlib.pyplot as plt
X = [590, 540, 740, 130, 810, 300, 320, 230, 470, 620, 770, 250]
Y = [32, 36, 39, 52, 61, 72, 77, 75, 68, 57, 48, 48]

plt.histogram(X, Y)
plt.show()
def make_plot_observed(fname, bins=None, norm=None):

    d = pl.genfromtxt(fname, names=True, invalid_raise=False)

    # observed quantities
    Z = pl.array([chargeNumber(id) for id in d['ID'].astype(int)])  # element
    A = pl.array([massNumber(id)
                  for id in d['ID'].astype(int)])  # atomic mass number
    lE = pl.log10(d['E']) + 18  # energy in log10(E/eV))

    if bins == None:
        lEbins = pl.arange(18, 20.51, 0.01)  # logarithmic bins
        lEcens = (lEbins[1:] + lEbins[:-1]) / 2  # logarithmic bin centers
    else:
        lEbins = pl.arange(17.5, 20.2, 0.1)  # logarithmic bins

    lEcens = (lEbins[1:] + lEbins[:-1]) / 2  # logarithmic bin centers
    dE = 10**lEbins[1:] - 10**lEbins[:-1]  # bin widths

    # identify mass groups
    EE = (10.0**lEcens)**3
    J1 = EE * pl.histogram(lE, bins=lEbins)[0] / dE
    J = np.zeros_like(J1)
    Jn = np.zeros([len(J1, 58)])
    for iz in range(1, 57):
        idx = (Z == iz)
        J += pl.histogram(lE[idx], bins=lEbins)[0] / dE

    # idx1 = A == 1
    # idx2 = (A > 1) * (A < 5)
    # idx3 = (A > 4) * (A < 23)
    # idx4 = (A > 22) * (A < 39)

    # # calculate spectrum: J(E) = dN/dE, we want E^3 J(E)
    # EE = (10.0 ** lEcens) ** 3

    #lum = np.sum(J * dE)
    # J  = EE * pl.histogram(lE, bins=lEbins)[0] / dE
    # J1 = EE * pl.histogram(lE[idx1], bins=lEbins)[0] / dE
    # J2 = EE * pl.histogram(lE[idx2], bins=lEbins)[0] / dE
    # J3 = EE * pl.histogram(lE[idx3], bins=lEbins)[0] / dE
    # J4 = EE * pl.histogram(lE[idx4], bins=lEbins)[0] / dE

    # normalize the histograms
    # if norm == None:
    # 	norm = 1.0 / J[0]
    # else:
    # 	norm = norm / J[10]
    norm = 1.0 / J[0]

    J1 *= norm
    # J2 *= norm
    # J3 *= norm
    # J4 *= norm
    J *= norm

    pl.plot(lEcens, smooth(J), color='k', linewidth=3, label="Total")
    pl.plot(lEcens, smooth(J1), color='#e84118', label='A = 1')
    pl.plot(lEcens, smooth(J2), color="#7f8fa6", label='A = 2-4')
    pl.plot(lEcens, smooth(J3), color="#44bd32", label='A = 5-22')
    pl.plot(lEcens, smooth(J4), color="#00a8ff", label='A = 23-38')

    pl.legend(fontsize=20, frameon=True, loc=3)
    pl.semilogy()
    #pl.ylim(1e-5)
    pl.grid()
    pl.ylabel('$E^3 J(E)$ [a.u.]')
    pl.xlabel('$\log_{10}$(E/eV)')
Пример #6
0
def plot_folds(linear_filename, bbox):
    import fracpaq as fpq
    import matplotlib.pylab as plt
    import sys
    import numpy as np

    linear = gpd.read_file(linear_filename)
    folds = linear[linear['feature'].str.contains("Fold")]
    folds = folds.dropna(subset=['geometry'])

    f = open('fold.txt', 'w')
    for inf, fold in folds.iterrows():
        for coords in fold['geometry'].coords:
            ostr = "{}\t{}\t".format(coords[0], coords[1])
            f.write(ostr)
        f.write('\n')
    f.close()

    fn = 'fold.txt'
    #   defaults
    CM2INCHES = 0.3937
    bGrid = False
    bEqualArea = False
    nBinWidth = 5
    sColour = 'C0'
    xSize = 15.0 * CM2INCHES
    ySize = 15.0 * CM2INCHES

    #   get nodes and calculate angles from nodes
    nodelist = fpq.getNodes(fn)
    xnodelist = nodelist[0]
    ynodelist = nodelist[1]
    segangle = fpq.getSegAngles(xnodelist, ynodelist)
    nSegs = len(segangle)
    if (nSegs > 0):
        #   bin the data and find maximum per bin
        nBins = int(round(360 / nBinWidth))
        segangleDoubled = np.zeros(len(segangle))
        segangleDoubled = np.copy(segangle)
        segangleDoubled = np.concatenate(
            [segangleDoubled, segangleDoubled + 180.0])
        n, b = plt.histogram(segangleDoubled, nBins)
        nMax = max(n)

        #   plot the segment angle distribution
        plt.figure(figsize=(xSize, ySize))
        plt.subplot(111, projection='polar')
        coll = fpq.rose(segangle,
                        bins=nBins,
                        bidirectional=True,
                        eqarea=True,
                        color=sColour)
        plt.xticks(np.radians(range(0, 360, 45)),
                   ['0', '45', '90', '135', '180', '215', '270', '315'])
        if (nMax > 6):
            plt.rgrids(range(0, int(round(nMax * 1.1)),
                             int(round((nMax * 1.1) / 5))),
                       angle=330)
        plt.ylim(0, int(round(nMax * 1.1)))
        plt.title('Segment strikes, n=%i' % nSegs)
        plt.savefig("folds_rose.pdf")
        #folds.plot(figsize=(7,7),edgecolor='#ff0000',linewidth=0.3)
        #print('Plotted %5d segments & angles' % nSegs)
        #plt.savefig('folds.pdf')
        plt.title('Fold axial traces')
        plt.show()
def plot():
    plt.histogram(sale_price)
    plt.axvline(x=sale_price.mean())
    plt.axvline(x=sale_price.median())
    plt.axvline(x=sale_price.mode())