コード例 #1
0
ファイル: wasserguete.py プロジェクト: pschwede/wasserguete
def timelines(info, years):
    for j, substance in enumerate(info):
        tuples = [row for row in itertools.chain(*info[substance].values())]
        tuples = sorted(tuples, key=lambda x: x["datetime"])

        x = np.array([i["datetime"] for i in tuples])
        y = np.array([i["value"] for i in tuples])

        fig, ax = pyplot.subplots()

        ax.scatter(x, y, color="none", linewidth=1, edgecolor="black")
        # ax.scatter(x, y, color="none", linewidth=1, edgecolor=color_palette(j, len(info)))
        etframes.add_dot_dash_plot(ax, ys=y)

        pyplot.title(u"%s im Oberfl\u00E4chenwasser (\u00B5g/l)" % substance)
        fig.autofmt_xdate()
        fig.set_size_inches(16, 9)
        fig.savefig("%s.png" % substance, format="png", dpi=100, bbox_inches="tight")
        gc.collect()
コード例 #2
0
ファイル: ex_poss.py プロジェクト: jliberma/rugby7s
plt.ylabel("Seconds")
plt.xlabel("")
plt.title("Average time of possession")
plt.savefig("7s_poss_avg.png")
plt.clf()

# convert min:sec columns to sec
fp[['T1t','T2t']] = fp[['T1t','T2t']].applymap(to_seconds)

# combine both teams to single data series
p = fp.T1p.append(fp.T2p)
t = fp.T1t.append(fp.T2t)

# plot relationship between time of possession and scoring
allteams=jitter(t,p,c=".5")
etframes.add_dot_dash_plot(plt.gca(), ys=p, xs=t)
plt.ylim(-5,65)
plt.xlim(0,400)

# add mean scoring/time of possession lines to the plot
mt = np.mean(t)
mp = np.mean(p)
tmax = np.max(p)
plt.plot([mt,mt],plt.gca().get_ylim(), linestyle="--")
plt.plot(plt.gca().get_xlim(),[mp,mp], linestyle="--")

# label the graph
plt.ylabel("Points")
plt.xlabel("Possession (seconds)")
plt.title("Scoring and time of possession in rugby 7s")
コード例 #3
0
plt.ylabel("Seconds")
plt.xlabel("")
plt.title("Average time of possession")
plt.savefig("7s_poss_avg.png")
plt.clf()

# convert min:sec columns to sec
fp[['T1t', 'T2t']] = fp[['T1t', 'T2t']].applymap(to_seconds)

# combine both teams to single data series
p = fp.T1p.append(fp.T2p)
t = fp.T1t.append(fp.T2t)

# plot relationship between time of possession and scoring
allteams = jitter(t, p, c=".5")
etframes.add_dot_dash_plot(plt.gca(), ys=p, xs=t)
plt.ylim(-5, 65)
plt.xlim(0, 400)

# add mean scoring/time of possession lines to the plot
mt = np.mean(t)
mp = np.mean(p)
tmax = np.max(p)
plt.plot([mt, mt], plt.gca().get_ylim(), linestyle="--")
plt.plot(plt.gca().get_xlim(), [mp, mp], linestyle="--")

# label the graph
plt.ylabel("Points")
plt.xlabel("Possession (seconds)")
plt.title("Scoring and time of possession in rugby 7s")
コード例 #4
0
ファイル: demo_ddp.py プロジェクト: yilangxu/tools
from numpy.random import *
from pylab import *

import etframes


ys = [normal() for _ in range(100)]
xs = [normal() for _ in range(100)]

scatter(xs,ys)

etframes.add_dot_dash_plot(gca(), ys=ys, xs=xs)


show()

コード例 #5
0
ファイル: make_plots.py プロジェクト: whigg/eddies
        yp[nanind] = np.nan
        del (xg, yg)  # don't need grid info anymore

        # Plot drifter tails for 3 days
        i3 = find(days > days[itdrifter] - 3)[0]

        ax.plot(xp[:, i3:itdrifter + 1].T,
                yp[:, i3:itdrifter + 1].T,
                '-',
                color='0.5',
                zorder=2,
                linewidth=.01)
        ax.plot(xp[:, itdrifter],
                yp[:, itdrifter],
                '.',
                color='0.3',
                alpha=0.5,
                zorder=3,
                markersize=0.75)

        if tufte:
            xpsave.extend(xp[:, itdrifter])
            ypsave.extend(yp[:, itdrifter])

    # Add Tufte-esque dot-dash if desired, where drifters are currently located
    if tufte:
        etframes.add_dot_dash_plot(ax, ys=ypsave, xs=xpsave)

    plt.savefig(figname, bbox_inches='tight', dpi=100)
    plt.close(fig)
コード例 #6
0
ファイル: make_plots.py プロジェクト: kthyng/eddies
        itdrifter = find(tg==t)[0] # find index in drifter time for drifters

        # Days back from this time
        days = (tg-tg[0])/(3600.*24)

        # Change to projected drifter locations now
        # indices where nans are location in xg, yg; for reinstitution of nans; also where grid points go to -1 before naning
        # also within 5 grid cells of the numerical boundary where the sponge layer is
        # pdb.set_trace()
        nanind = np.isnan(xg) + (xg==-1) + (np.ceil(xg)<=5) + (np.ceil(xg)>=grid['xr'].shape[0]-5) + (np.ceil(yg)<=5)
        xp, yp, _ = tracpy.tools.interpolate2d(xg, yg, grid, 'm_ij2xy') 
        xp[nanind] = np.nan; yp[nanind] = np.nan
        del(xg,yg) # don't need grid info anymore

        # Plot drifter tails for 3 days
        i3 = find(days>days[itdrifter]-3)[0]

        ax.plot(xp[:,i3:itdrifter+1].T, yp[:,i3:itdrifter+1].T, '-', color='0.5', zorder=2, linewidth=.01)
        ax.plot(xp[:,itdrifter], yp[:,itdrifter], '.', color='0.3', alpha=0.5, zorder=3, markersize=0.75)

        if tufte:
            xpsave.extend(xp[:,itdrifter]); ypsave.extend(yp[:,itdrifter])

    # Add Tufte-esque dot-dash if desired, where drifters are currently located
    if tufte:
        etframes.add_dot_dash_plot(ax, ys=ypsave, xs=xpsave)

    plt.savefig(figname, bbox_inches='tight', dpi=100)
    plt.close(fig)