Exemplo n.º 1
0
def get_graphs(dataframe):

    # TODO: see https://stackoverflow.com/questions/40783669/stacked-bar-plot-by-group-count-on-pandas-python
    fig = plt.figure(figsize=(10, 10))
    fig_dims = (3, 2)

    # Histogram: Limit
    plt.subplot2grid(fig_dims, (0, 0))
    df["limit"].hist()
    plt.title("Limit Histogram")
    plt.show()

    # Gender counts
    df["sex"].value_counts().plot(kind="bar", title="Gender Counts")
    plt.show()

    # For stacked barplor: obtain count of possible att values
    n_male = int(df[df["sex"] == "male"]["sex"].value_counts())
    n_female = int(df[df["sex"] == "female"]["sex"].value_counts())
Exemplo n.º 2
0
def ts_plot(y, lags=None, title='', figsize=(14, 8)):
    """Examine the patterns of ACF and PACF, along with the time series plot and histogram.

    Original source: https://tomaugspurger.github.io/modern-7-timeseries.html
    """
    fig = plt.figure(figsize=figsize)
    layout = (2, 2)
    ts_ax = plt.subplot2grid(layout, (0, 0))
    hist_ax = plt.subplot2grid(layout, (0, 1))
    acf_ax = plt.subplot2grid(layout, (1, 0))
    pacf_ax = plt.subplot2grid(layout, (1, 1))

    y.plot(ax=ts_ax)
    ts_ax.set_title(title)
    y.plot(ax=hist_ax, kind='hist', bins=25)
    hist_ax.set_title('Histogram')
    smt.graphics.plot_acf(y, lags=lags, ax=acf_ax)
    smt.graphics.plot_pacf(y, lags=lags, ax=pacf_ax)
    [ax.set_xlim(0) for ax in [acf_ax, pacf_ax]]
    sns.despine()
    plt.tight_layout()
    return ts_ax, acf_ax, pacf_ax
Exemplo n.º 3
0
def save_cloud_fig(data_in, x1, x2, y1, y2, font_size_label, name):

    in_sep = max(loc for loc, val in enumerate(name) if val == '/')

    str_time = name[in_sep + 1:in_sep + 18]

    yyyy = str_time[0:4]
    mm = str_time[5:7]
    dd = str_time[8:10]

    hh = str_time[11:13]
    MM = str_time[13:15]
    ss = str_time[15:17]

    timestamp = str(dd) + '/' + str(mm) + '/' + str(yyyy) + ' ' + str(
        hh) + ':' + str(MM) + ':' + str(ss)
    #-----------------------------------------------------------------------------#
    #-----------------------------------------------------------------------------#
    fig = plt.figure(1)
    #-----------------------------------------------------------------------------#

    fig_cloud = plt.subplot2grid((6, 2), (2, 1), rowspan=4, colspan=1)
    #-   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -#
    plt.imshow(data_in, aspect=1)

    plt.title(timestamp)
    #-   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -#
    plt.axis([x1, x2, y1, y2])
    plt.xlabel(r'$pixel$', fontsize=font_size_label)
    fig_cloud.xaxis.set_label_position("bottom")
    #plt.xticks([0,512,1024], fontsize = font_size_ticks)
    fig_cloud.xaxis.tick_bottom()

    plt.ylabel(r'$pixel$', fontsize=font_size_label)
    fig_cloud.yaxis.set_label_position("right")
    #plt.yticks([0,512,1024], fontsize = font_size_ticks)
    fig_cloud.yaxis.tick_right()
    #-----------------------------------------------------------------------------#

    #-----------------------------------------------------------------------------#
    fig.savefig(str(name) + '.png', bbox_inches='tight', dpi=300)
    #-----------------------------------------------------------------------------#
    #-----------------------------------------------------------------------------#


###############################################################################
def func(x,A,B):
	return A*exp(-B*x)/x

par_guess = (50.0,3000.0)

#popt, pcov = curve_fit(func,data['wheel_speed'],Abut_Stress,p0=par_guess) #issues with NaNs or infs

#print popt
#print pcov


#---------------Wheel Speed vs Abutment Stress Graph Plot----------------

fig = plt.figure()
ax = plt.subplot2grid((2,2),(0,0),rowspan=2,colspan=2)


colour = data['abut_temp_c']

plot2 = ax.scatter(data['wheel_speed'], Abut_Stress, linewidth = 0, marker='o',s=10, c=colour)

fig.colorbar(plot2,cmap=cm.CMRmap, norm=Normalize(clip=False),label = 'Abutment Temperature')


#ax.plot(xdata,(par_guess[0]/xdata)*exp(-par_guess[1]*xdata))

#---------Settings for the second figure window---------------

ax.set_ylim(0,2000)
ax.set_xlim(0,12)
Exemplo n.º 5
0
log("original_image", original_image)
log("image_meta", image_meta)
log("gt_class_id", gt_class_id)
log("gt_bbox", gt_bbox)
log("gt_mask", gt_mask)

# Preparing grid plot
"""
ax1 = plt.subplot2grid((3, 3), (0, 0), colspan=3)
ax2 = plt.subplot2grid((3, 3), (1, 0), colspan=2)
ax3 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)
ax4 = plt.subplot2grid((3, 3), (2, 0))
ax5 = plt.subplot2grid((3, 3), (2, 1))
"""
ax1 = plt.subplot2grid((1, 2), (0, 0))
ax2 = plt.subplot2grid((1, 2), (0, 1))

visualize.display_instances(
    original_image,
    gt_bbox,
    gt_mask,
    gt_class_id,
    #                            dataset_train.class_names, ax=ax1)
    dataset_train.class_names,
    figsize=(8, 8))
#                            dataset_train.class_names,  ax=get_ax())

results = model.detect([original_image], verbose=1)

r = results[0]
Exemplo n.º 6
0
in_mk = mk_prep([i.isoformat() for i in middate[win]],d.mb[win])
gul_mk = mk_prep([i.isoformat() for i in midgulx],midguly)
wol_mk = mk_prep([i.isoformat() for i in midwolx],midwoly)

wgul1993 = N.where(N.array([g.year for g in gulx])>1993)[0]
wwol1993 = N.where(N.array([g.year for g in wolx])>1993)[0]

gul_time_mk = mk_prep([i.isoformat() for i in N.array(gulx)[wgul1993]],N.array(guly)[wgul1993])  # cutting the timeseries down to 1994-2014
wol_time_mk = mk_prep([i.isoformat() for i in N.array(wolx)[wwol1993]],N.array(woly)[wwol1993])  # cutting the timeseries down to 1994-2014

trendstats =  (mk_test(se_mk, alpha = 0.05),mk_test(sc_mk, alpha = 0.05),mk_test(in_mk, alpha = 0.05),mk_test(gul_time_mk, alpha = 0.05),mk_test(gul_time_mk, alpha = 0.05),mk_test(wol_time_mk, alpha = 0.05))


#FIGURE SETUP
fig = plt.figure(figsize=[4,7])
ax1 = plt.subplot2grid((8,1), (6, 0), rowspan=2)
ax2 = plt.subplot2grid((8,1), (4, 0), rowspan=2)
ax3 = plt.subplot2grid((8,1), (2, 0), rowspan=2)
ax4 = plt.subplot2grid((8,1), (0, 0), rowspan=2)
fig.subplots_adjust(hspace=0.04,bottom=0.1,left=0.14,top=0.98,right=0.98)
plt.rc("font", **{"sans-serif": ["Arial"],"size": 11})

#DATE FORMATTER
years    = mdates.YearLocator(2)   # every year
yearsFmt = mdates.DateFormatter('%Y')

#PLOTTING POINTS
ax1.plot_date(middate[wse],d.mb[wse],'ko',alpha = 0.5,markersize=4,zorder=5)
ax2.plot_date(middate[wsc],d.mb[wsc],'ko',alpha = 0.5,markersize=4,zorder=5)
ax3.plot_date(middate[win],d.mb[win],'ko',alpha = 0.5,markersize=4,zorder=5)
ax1.plot_date([N.array(d.date1)[wse],N.array(d.date2)[wse]],[d.mb[wse],d.mb[wse]],'-k',alpha = 0.2)
Exemplo n.º 7
0
import matplotlib.pyplot as plt
from matplotlib.finance import candlestick_ohlc

# In[73]:

import matplotlib.ticker as mticker

# In[79]:

date = df.Date.values

# In[87]:

fig = plt.figure()
f1 = plt.subplot2grid((6, 4), (1, 0), rowspan=6, colspan=4)
candlestick_ohlc(f1,
                 df1.values,
                 width=1 / len(df1) * 0.6,
                 colorup='k',
                 colordown='r',
                 alpha=0.75)

ax2 = plt.subplot2grid((5, 4), (4, 0), sharex=f1, rowspan=1, colspan=4)
ax2.bar(range(len(date)), df.Volume.values)
ax2.axes.yaxis.set_ticklabels([])
plt.ylabel('Volume')
ax2.grid(True)
for label in ax2.xaxis.get_ticklabels():
    label.set_rotation(45)