def plot_all_cases_maps_prof(var1,
                             relative=True,
                             width_ratios=[3, .7, 1.8],
                             plot_significance=False,
                             asp_rat=.55,
                             width=6.8):
    #varl_map=None
    nvars = 1
    fig = plt.figure(figsize=[width * nvars, asp_rat * width * nvars])
    gs = gridspec.GridSpec(2, nvars + 2, width_ratios=width_ratios)
    ax_prof = plt.subplot(gs[:, 0])
    ax_labs = plt.subplot(gs[:, 1])
    ax_maps1 = plt.subplot(gs[0, 2], projection=ccrs.Robinson())
    ax_maps2 = plt.subplot(gs[1, 2], projection=ccrs.Robinson())
    axs_maps = [ax_maps1, ax_maps2]
    linestd = dict()
    linestd_nn = dict()
    varl = [var1]  #,'SO4_NA']

    profiles_sub(areas, ax_prof, cases, linestd, linestd_nn, var1, varl)
    linestd = dict()
    linestd_nn = dict()
    for case, ls in zip(cases, linests):
        linestd[case] = ls
        linestd_nn[get_nice_name_case(case)] = ls
    ax = ax_prof  # plt.subplots(1, figsize=[6,8])
    cases_nn = [get_nice_name_case(case) for case in cases]
Beispiel #2
0
def plot_prof_map_together(var, areas, cases, axs, var_map=None, map_kwargs={}):
    if axs is None:
        fig = plt.figure(figsize = [width,asp_rat*width])
        gs = gridspec.GridSpec(2, 2,height_ratios=[1,1.], width_ratios=[5,1])#width_ratios=[2, 1]) 
        ax1 = plt.subplot(gs[1,0])
        ax2 = plt.subplot(gs[1,1])
        ax3 = plt.subplot(gs[0,:], projection=ccrs.Robinson())
        axs=[ax1,ax2,ax3]
        ax2.axis('off')
        cases_nn = [get_nice_name_case(case) for case in cases]
Beispiel #3
0
def plot_levlat_map_together(var, areas, cases, axs, var_map=None,
                            ylim = [1e3, 100], relative=True,
                             yscale='log',
                             cba_kwargs=None,
                             cbar_orientation='horizontal'
                            ):
    if axs is None:
        fig = plt.figure(figsize = [width,asp_rat*width])
        gs = gridspec.GridSpec(2, 2,height_ratios=[1,1.], width_ratios=[5,1])#width_ratios=[2, 1]) 
        ax1 = plt.subplot(gs[1,0])
        ax2 = plt.subplot(gs[1,1])
        ax3 = plt.subplot(gs[0,:], projection=ccrs.Robinson())
        axs=[ax1,ax2,ax3]
        ax2.axis('off')
        cases_nn = [get_nice_name_case(case) for case in cases]
Beispiel #4
0
def plt_prof_map_together_ls(var1,
                             var2,
                             areas,
                             cases,
                             asp_rat=1,
                             width=5.5,
                             varl_map=None):
    nvars = 2
    fig = plt.figure(figsize=[width * nvars, asp_rat * width * nvars])
    gs = gridspec.GridSpec(2,
                           nvars + 1,
                           height_ratios=[1, 1.],
                           width_ratios=[5, 5, 1])  #width_ratios=[2, 1])
    axs_prof = []
    axs_maps = []
    ax1 = plt.subplot(gs[1, 0])
    ax2 = None  #plt.subplot(gs[1,1+i*2])
    ax3 = plt.subplot(gs[0, 0], projection=ccrs.Robinson())
    print(var1, areas, cases, [ax1, ax3])
    if varl_map is None:
        var1m = None
        var2m = None
    else:
        var1m = varl_map[0]
        var2m = varl_map[1]

    plot_prof_map_together(var1, areas, cases, [ax1, ax3], var_map=var1m)
    axs_maps.append(ax3)
    axs_prof.append(ax1)
    ax1 = plt.subplot(gs[1, 1])
    ax2 = plt.subplot(gs[1, 2])
    ax3 = plt.subplot(gs[0, 1], projection=ccrs.Robinson())
    plot_prof_map_together(var2, areas, cases, [ax1, ax3], var_map=var2m)
    axs_maps.append(ax3)
    axs_prof.append(ax1)

    ax2.axis('off')
    linestd = dict()
    linestd_nn = dict()
    for case, ls in zip(cases, linests):
        linestd[case] = ls
        linestd_nn[get_nice_name_case(case)] = ls
    ax = ax1  # plt.subplots(1, figsize=[6,8])
    cases_nn = [get_nice_name_case(case) for case in cases]
Beispiel #5
0
def plt_prof_map_together(var, areas, cases, asp_rat=1, width=6):
    fig = plt.figure(figsize=[width, asp_rat * width])
    gs = gridspec.GridSpec(2, 2, height_ratios=[1, 1.],
                           width_ratios=[5, 1])  #width_ratios=[2, 1])
    ax1 = plt.subplot(gs[1, 0])
    ax2 = plt.subplot(gs[1, 1])
    ax3 = plt.subplot(gs[0, :], projection=ccrs.Robinson())
    ax2.axis('off')

    cmapd = get_cmap_dic(areas)

    linestd = dict()
    linestd_nn = dict()
    for case, ls in zip(cases, linests):
        linestd[case] = ls
        linestd_nn[get_nice_name_case(case)] = ls
    ax = ax1  # plt.subplots(1, figsize=[6,8])

    for area in areas:
        prof_dic = get_averaged_fields.get_profiles(
            cases, [var],
            startyear,
            endyear,
            area=area,
            pressure_adjust=pressure_adjust)

        for case in cases:
            kwargs = dict(color=get_area_col(area), linestyle=linestd[case])
            plot_profile(prof_dic[case][var],
                         ax=ax,
                         kwargs=kwargs,
                         xscale='log',
                         label=case + ', ' + area,
                         ylim=[1000, 200])  #,
    ax.grid(False, which='both')
    sns.despine(ax=ax)
    ax.set_yscale('log')

    set_scalar_formatter(ax)
    cases_nn = [get_nice_name_case(case) for case in cases]
#axs_prof[0].set_xlim([1e-13,5e-11])
#axs_prof[1].set_xlim([1e-13,5e-11])
#plt.savefig(fn_figure + 'png')
#plt.savefig(fn_figure + 'pdf', dpi=300)
axs_prof.set_xscale('log')
#axs_prof.set_yxscale([10,1e3])
plt.show()

# %%
# %%
asp_rat = .55
width = 6.8
relative = True
varl_map = None
nvars = 1
fig = plt.figure(figsize=[width * nvars, asp_rat * width * nvars])
gs = gridspec.GridSpec(2, nvars + 2, width_ratios=[3, .7, 1.9])
axs_prof = []
axs_maps = []
ax1 = plt.subplot(gs[:, 0])
ax_labs = plt.subplot(gs[:, 1])
ax_maps1 = plt.subplot(gs[0, 2], projection=ccrs.Robinson())
ax_maps2 = plt.subplot(gs[1, 2], projection=ccrs.Robinson())
var1 = 'NMR01'

linestd = dict()
linestd_nn = dict()
varl = [var1]  #,'SO4_NA']

profiles_sub(areas, ax1, cases, linestd, linestd_nn, var1, varl)
linestd = dict()
Beispiel #7
0
                                       'principal component 2',
                                       'principal component 3'
                                   ])

# %%
principal_breast_Df.tail()

# %%
print('Explained variation per principal component: {}'.format(
    pca_breast.explained_variance_ratio_))

# %%
pca_breast.components_

# %%
plt.figure()
plt.figure(figsize=(10, 10))
plt.xticks(fontsize=12)
plt.yticks(fontsize=14)
plt.xlabel('Principal Component - 1', fontsize=20)
plt.ylabel('Principal Component - 2', fontsize=20)
plt.title("Principal Component Analysis of Breast Cancer Dataset", fontsize=20)
targets = _df['NCONC_cat'].unique()
colors = ['r', 'b', 'y', 'g']
#colors = ['r', 'g']
#plt.scatter(principal_breast_Df['principal component 1']
#            , principal_breast_Df['principal component 2'], c=_df['NCONC01'])
for target, color in zip(targets, colors):
    indicesToKeep = _df['NCONC_cat'] == target
    plt.scatter(principal_breast_Df.loc[indicesToKeep.values,
                                        'principal component 1'],