Esempio n. 1
0
def plot_planes(X, y, local_model, central_model, dist_model):
    sns.set_style('ticks')

    y = pd.DataFrame(y)
    y.loc[y[0] == -1, 0] = colors.to_hex(cm.Pastel2(0))
    y.loc[y[0] == 1, 0]  = colors.to_hex(cm.Pastel2(1))
    y = y.values.T[0]

    w, b = get_average_best_plane(dist_model)

    plt.figure()
    draw_plane(w,
               b,
               cm.tab10(0),
               1,
               2.2,
               '-',
               "SVM Distribuído com C = " + str(dist_model.C) + " e " + "c = " + str(dist_model.c))
    draw_plane(central_model.coef_[0],
               central_model.intercept_[0],
               cm.tab10(1),
               1,
               2.2,
               '--',
               "SVM Central com C = " + str(central_model.get_params()['C']))
    draw_plane(local_model.coef_[0],
               local_model.intercept_[0],
               cm.tab10(2),
               1,
               2.2,
               '-.',
               "SVM Local com C = " + str(local_model.get_params()['C']))


    plt.scatter(X[:, 0], X[:, 1], marker = 'o', c = y, alpha = 0.5)
    sns.despine()
    plt.legend(loc = 2)
    plt.ylim(-4.8, 4.8)
    file = str(plots_path) + "/simple_graph_compare.pdf"
    plt.savefig(file, transparent = True)
Esempio n. 2
0
from PIL import Image
import webbrowser
from wordcloud import WordCloud, STOPWORDS
import subprocess
from datetime import datetime
import networkx as nx
import nxviz as nxv

#####
from matplotlib import cm
words = ['Biological Process', 'Molecular Function', 'Cellular Component']
pie_colors = {
    'Set3': cm.Set3(np.arange(12) / 12.),
    'Set2': cm.Set2(np.arange(8) / 8.),
    'Set1': cm.Set1(np.arange(9) / 9.),
    'Pastel2': cm.Pastel2(np.arange(8) / 8.),
    'Pastel1': cm.Pastel1(np.arange(9) / 9.),
    'Dark2': cm.Dark2(np.arange(8) / 8.),
    'Paired': cm.Paired(np.arange(12) / 12.),
    'Accent': cm.Accent(np.arange(8) / 8.),
    'Spectral': cm.Spectral(np.arange(11) / 11.)
}
colors = {
    '#8DD3C7': pie_colors['Set3'][0:1],
    '#FFFFB3': pie_colors['Set3'][1:2],
    '#BEBADA': pie_colors['Set3'][2:3],
    '#FB8072': pie_colors['Set3'][3:4],
    '#80B1D3': pie_colors['Set3'][4:5],
    '#FDB462': pie_colors['Set3'][5:6],
    '#B3DE69': pie_colors['Set3'][6:7],
    '#FCCDE5': pie_colors['Set3'][7:8],
Esempio n. 3
0
def generate__colors(colorType="default",
                     nColors=10,
                     seaborn=True,
                     howto=False):

    if (howto == True):
        print(
            "[generate__colors.py] generate__colors( colorType=, nColors=, seaborn=T/F, howto=T/F )"
        )
        print( "[generate__colors.py] colorType = [ \ \n"\
               "default, bright, deep, muted, colorblind, pastel, \n"\
               "jet, tab10, tab20, hsv, accent, pastel1, pastel2, set1, set2, set3 \n"\
               " ] ")
        return ()

    # ------------------------------------------------- #
    # --- [1] generate colors                       --- #
    # ------------------------------------------------- #

    if (not (seaborn)):

        if (colorType.lower() == "jet"):
            colors = [cm.jet(ik / float(nColors)) for ik in range(nColors)]

        elif (colorType.lower() == "tab10"):
            colors = [cm.tab10(ik / float(nColors)) for ik in range(nColors)]

        elif (colorType.lower() == "tab20"):
            colors = [cm.tab20(ik / float(nColors)) for ik in range(nColors)]

        elif (colorType.lower() == "hsv"):
            colors = [cm.hsv(ik / float(nColors)) for ik in range(nColors)]

        elif (colorType.lower() == "accent"):
            colors = [cm.Accent(ik / float(nColors)) for ik in range(nColors)]

        elif (colorType.lower() == "pastel1"):
            colors = [cm.Pastel1(ik / float(nColors)) for ik in range(nColors)]

        elif (colorType.lower() == "pastel2"):
            colors = [cm.Pastel2(ik / float(nColors)) for ik in range(nColors)]

        elif (colorType.lower() == "set1"):
            colors = [cm.Set1(ik / float(nColors)) for ik in range(nColors)]

        elif (colorType.lower() == "set2"):
            colors = [cm.Set2(ik / float(nColors)) for ik in range(nColors)]

        elif (colorType.lower() == "set3"):
            colors = [cm.Set3(ik / float(nColors)) for ik in range(nColors)]

        else:
            print("[generate__colors.py] colorType  == ?? ")
            sys.exit()

    else:

        if (colorType.lower() == "jet"):
            print("[generate__colors.py]  no jet palette for seaborn")
            sys.exit()

        elif (colorType.lower() == "default"):
            colors = sns.color_palette(n_colors=nColors)

        elif (colorType.lower() == "deep"):
            colors = sns.color_palette(palette="deep", n_colors=nColors)

        elif (colorType.lower() == "colorblind"):
            colors = sns.color_palette(palette="colorblind", n_colors=nColors)

        elif (colorType.lower() == "dark"):
            colors = sns.color_palette(palette="dark", n_colors=nColors)

        elif (colorType.lower() == "bright"):
            colors = sns.color_palette(palette="bright", n_colors=nColors)

        elif (colorType.lower() == "muted"):
            colors = sns.color_palette(palette="muted", n_colors=nColors)

        elif (colorType.lower() == "pastel"):
            colors = sns.color_palette(palette="pastel", n_colors=nColors)

        elif (colorType.lower() == "hsv"):
            colors = sns.color_palette(palette="hsv", n_colors=nColors)

        elif (colorType.lower() == "accent"):
            colors = sns.color_palette(palette="Accent", n_colors=nColors)

        elif (colorType.lower() == "pastel1"):
            colors = sns.color_palette(palette="Pastel1", n_colors=nColors)

        elif (colorType.lower() == "pastel2"):
            colors = sns.color_palette(palette="Pastel2", n_colors=nColors)

        elif (colorType.lower() == "tab10"):
            colors = sns.color_palette(palette="tab10", n_colors=nColors)

        elif (colorType.lower() == "tab20"):
            colors = sns.color_palette(palette="tab20", n_colors=nColors)

        elif (colorType.lower() == "set1"):
            colors = sns.color_palette(palette="Set1", n_colors=nColors)

        elif (colorType.lower() == "set2"):
            colors = sns.color_palette(palette="Set2", n_colors=nColors)

        elif (colorType.lower() == "set3"):
            colors = sns.color_palette(palette="Set3", n_colors=nColors)

        else:
            colors = sns.color_palette(palette=colorType, n_colors=nColors)

    # ------------------------------------------------- #
    # --- [2] return                                --- #
    # ------------------------------------------------- #
    return (colors)
Esempio n. 4
0
def df_input(dfUniprot=DataFrame([])):

    num_phylum = len(dfUniprot.PHYLUM.drop_duplicates())
    from matplotlib import cm
    set3 = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.Set3(np.arange(12) / 12.)
    ]
    set2 = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.Set2(np.arange(8) / 8.)
    ]
    set1 = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.Set1(np.arange(9) / 9.)
    ]
    pastel2 = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.Pastel2(np.arange(8) / 8.)
    ]
    pastel1 = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.Pastel1(np.arange(9) / 9.)
    ]
    dark2 = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.Dark2(np.arange(8) / 8.)
    ]
    paired = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.Paired(np.arange(12) / 12.)
    ]
    accent = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.Accent(np.arange(8) / 8.)
    ]
    spectral = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.Spectral(np.arange(11) / 11.)
    ]
    tab20 = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.tab20(np.arange(20) / 20.)
    ]
    tab20b = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.tab20b(np.arange(20) / 20.)
    ]
    tab20c = [
        matplotlib.colors.rgb2hex(tuple(i))
        for i in cm.tab20c(np.arange(20) / 20.)
    ]

    Colors1 = set2 + set1 + dark2 + paired + accent + spectral + tab20 + tab20b + tab20c
    Colors2 = accent + spectral + tab20 + tab20b + tab20c + set1 + set2 + dark2 + paired
    Colors3 = dark2 + paired + accent + spectral + tab20 + tab20b + tab20c + set1 + set2
    Colors4 = tab20b + tab20c + set1 + set2 + dark2 + paired + accent + spectral + tab20
    Colors5 = spectral + tab20 + tab20b + tab20c + set1 + set2 + dark2 + paired + accent

    pie_colors = {
        'Set3': cm.Set3(np.arange(12) / 12.),
        'Set2': cm.Set2(np.arange(8) / 8.),
        'Set1': cm.Set1(np.arange(9) / 9.),
        'Pastel2': cm.Pastel2(np.arange(8) / 8.),
        'Pastel1': cm.Pastel1(np.arange(9) / 9.),
        'Dark2': cm.Dark2(np.arange(8) / 8.),
        'Paired': cm.Paired(np.arange(12) / 12.),
        'Accent': cm.Accent(np.arange(8) / 8.),
        'Spectral': cm.Spectral(np.arange(11) / 11.),
        'tab20': cm.tab20(np.arange(20) / 20.),
        'tab20b': cm.tab20b(np.arange(20) / 20.),
        'tab20c': cm.tab20c(np.arange(20) / 20.)
    }
    circle_colors = {
        'Colors1': Colors1[0:num_phylum],
        'Colors2': Colors2[0:num_phylum],
        'Colors3': Colors3[0:num_phylum],
        'Colors4': Colors4[0:num_phylum],
        'Colors5': Colors5[0:num_phylum]
    }

    def tax_colors(color_list=circle_colors['Colors1'], taxx=dfUniprot):
        tax_cols = [
            'Entry', 'Tax_ID', 'KINGDOM', 'PHYLUM', 'CLASS', 'ORDER', 'FAMILY',
            'GENUS', 'SPECIES', 'Organism'
        ]
        new2 = taxx[tax_cols].drop_duplicates()
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>
        phylum0 = new2.groupby(['PHYLUM'
                                ]).Entry.count().reset_index().sort_values(
                                    by='Entry',
                                    ascending=False).reset_index(drop=True)
        asign_color = {}
        for i, j in zip(phylum0.PHYLUM, color_list):
            if i == 'NA':
                asign_color[i] = 'black'
            else:
                asign_color[i] = j
        phylum0['phy_col'] = list(asign_color.values())
        # distribución de Class
        phylum1 = new2.groupby(['PHYLUM', 'CLASS']).Entry.count().reset_index()
        class0 = []
        class0_colors = []
        for i in phylum0.PHYLUM:
            for j in phylum1.PHYLUM:
                if i == j:
                    class0_colors.append(asign_color[j])
                    class0.append(phylum1[phylum1.PHYLUM == i].sort_values(
                        by='Entry', ascending=False).reset_index(drop=True))
                else:
                    pass
        class1 = pd.concat(class0).drop_duplicates()
        class1['class_col'] = class0_colors
        class0_colors_corregido = []
        for index, row in class1.iterrows():
            if row.PHYLUM == 'NA':
                if row.CLASS == 'NA':
                    class0_colors_corregido.append(row.class_col)
                else:
                    class0_colors_corregido.append('grey')
            else:
                if row.CLASS == 'NA':
                    class0_colors_corregido.append('black')
                else:
                    class0_colors_corregido.append(row.class_col)
        class1['class_col'] = class0_colors_corregido
        class11 = class1.groupby(['CLASS'
                                  ]).Entry.sum().reset_index().sort_values(
                                      by='Entry',
                                      ascending=False).reset_index(drop=True)
        class11 = class11.merge(class1[['CLASS',
                                        'class_col']].drop_duplicates(),
                                on='CLASS',
                                how='left')
        # distribución de Order
        phylum2 = new2.groupby(['PHYLUM', 'CLASS',
                                'ORDER']).Entry.count().reset_index()
        order0 = []
        order0_colors = []
        for i in phylum0.PHYLUM:
            for j in phylum2.PHYLUM:
                if i == j:
                    order0_colors.append(asign_color[j])
                    order0.append(phylum2[phylum2.PHYLUM == i].sort_values(
                        by='Entry', ascending=False).reset_index(drop=True))
                else:
                    pass
        order1 = pd.concat(order0).drop_duplicates()
        order1['order_col'] = order0_colors
        order0_colors_corregido = []
        for index, row in order1.iterrows():
            if row.PHYLUM == 'NA':
                if row.ORDER == 'NA':
                    order0_colors_corregido.append(row.order_col)
                else:
                    order0_colors_corregido.append('grey')
            else:
                if row.ORDER == 'NA':
                    order0_colors_corregido.append('black')
                else:
                    order0_colors_corregido.append(row.order_col)
        order1['order_col'] = order0_colors_corregido
        order11 = order1.groupby(['ORDER'
                                  ]).Entry.sum().reset_index().sort_values(
                                      by='Entry',
                                      ascending=False).reset_index(drop=True)
        order11 = order11.merge(order1[['ORDER',
                                        'order_col']].drop_duplicates(),
                                on='ORDER',
                                how='left')
        # distribución de Genus
        phylum3 = new2.groupby(['PHYLUM', 'CLASS', 'ORDER',
                                'GENUS']).Entry.count().reset_index()
        genus0 = []
        genus0_colors = []
        for i in phylum0.PHYLUM:
            for j in phylum3.PHYLUM:
                if i == j:
                    genus0_colors.append(asign_color[j])
                    genus0.append(phylum3[phylum3.PHYLUM == i].sort_values(
                        by='Entry', ascending=False).reset_index(drop=True))
                else:
                    pass
        genus1 = pd.concat(genus0).drop_duplicates()
        genus1['genus_col'] = genus0_colors
        genus0_colors_corregido = []
        for index, row in genus1.iterrows():
            if row.PHYLUM == 'NA':
                if row.GENUS == 'NA':
                    genus0_colors_corregido.append(row.genus_col)
                else:
                    genus0_colors_corregido.append('grey')
            else:
                if row.GENUS == 'NA':
                    genus0_colors_corregido.append('black')
                else:
                    genus0_colors_corregido.append(row.genus_col)
        genus1['genus_col'] = genus0_colors_corregido
        genus11 = genus1.groupby(['GENUS'
                                  ]).Entry.sum().reset_index().sort_values(
                                      by='Entry',
                                      ascending=False).reset_index(drop=True)
        genus11 = genus11.merge(genus1[['GENUS',
                                        'genus_col']].drop_duplicates(),
                                on='GENUS',
                                how='left')
        # distribución de Organism
        phylum4 = new2.groupby(
            ['PHYLUM', 'CLASS', 'ORDER', 'GENUS',
             'Organism']).Entry.count().reset_index()
        org0 = []
        org0_colors = []
        for i in phylum0.PHYLUM:
            for j in phylum4.PHYLUM:
                if i == j:
                    org0_colors.append(asign_color[j])
                    org0.append(phylum4[phylum4.PHYLUM == i].sort_values(
                        by='Entry', ascending=False).reset_index(drop=True))
                else:
                    pass
        org1 = pd.concat(org0).drop_duplicates()
        org1['org_col'] = org0_colors
        org0_colors_corregido = []
        for index, row in org1.iterrows():
            if row.PHYLUM == 'NA':
                if row.Organism == 'NA':
                    org0_colors_corregido.append(row.org_col)
                else:
                    org0_colors_corregido.append('grey')
            else:
                if row.Organism == 'NA':
                    org0_colors_corregido.append('black')
                else:
                    org0_colors_corregido.append(row.org_col)
        org1['org_col'] = org0_colors_corregido
        org11 = org1.groupby(['Organism'
                              ]).Entry.sum().reset_index().sort_values(
                                  by='Entry',
                                  ascending=False).reset_index(drop=True)
        org11 = org11.merge(org1[['Organism', 'org_col']].drop_duplicates(),
                            on='Organism',
                            how='left')
        os.makedirs('tax', exist_ok=True)
        return phylum0.to_csv('tax/phylum0.tsv', sep = '\t', index = None),\
            class1.to_csv('tax/class1.tsv', sep = '\t', index = None),\
            class11.to_csv('tax/class11.tsv', sep = '\t', index = None),\
            order1.to_csv('tax/order1.tsv', sep = '\t', index = None),\
            order11.to_csv('tax/order11.tsv', sep = '\t', index = None),\
            genus1.to_csv('tax/genus1.tsv', sep = '\t', index = None),\
            genus11.to_csv('tax/genus11.tsv', sep = '\t', index = None),\
            org1.to_csv('tax/org1.tsv', sep = '\t', index = None),\
            org11.to_csv('tax/org11.tsv', sep = '\t', index = None)

    alfas = {
        'Lineage*': [1, 1, 1, 1, 1],
        'Phylum': [1, 0.3, 0.3, 0.3, 0.3],
        'Class': [0.3, 1, 0.3, 0.3, 0.3],
        'Order': [0.3, 0.3, 1, 0.3, 0.3],
        'Genus': [0.3, 0.3, 0.3, 1, 0.3],
        'Species': [0.3, 0.3, 0.3, 0.3, 1],
        'Gradient1*': [1, 0.85, 0.7, 0.55, 0.4],
        'Gradient2*': [0.4, 0.55, 0.7, 0.85, 1],
        'Attenuate*': [0.3, 0.3, 0.3, 0.3, 0.3],
        'None*': [0, 0, 0, 0, 0]
    }

    def circle_lineage(alphas=alfas['Phylum']):
        #fig, ax = plt.subplots(111, facecolor= 'white')
        #fig, ax = plt.subplot(111)
        phylum0 = pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA')
        class1 = pd.read_csv('tax/class1.tsv', sep='\t').fillna('NA')
        order1 = pd.read_csv('tax/order1.tsv', sep='\t').fillna('NA')
        genus1 = pd.read_csv('tax/genus1.tsv', sep='\t').fillna('NA')
        org1 = pd.read_csv('tax/org1.tsv', sep='\t').fillna('NA')

        radio = 0.5

        linaje = [phylum0, class1, order1, genus1, org1]
        #colores = [list(asign_color.values()), class0_colors, order0_colors, genus0_colors, org0_colors]
        colores = ['phy_col', 'class_col', 'order_col', 'genus_col', 'org_col']
        pat = []
        size = -.205
        for i, j, k in zip(linaje, colores, alphas):
            size += .205
            patches, texts = plt.pie(
                i.Entry,
                radius=radio + size,
                labels=None,
                labeldistance=0.8,
                rotatelabels=True,
                colors=
                i[j],  # new_colors(valor = len(i.Entry), col = 'nipy_spectral'),
                wedgeprops=dict(width=0.2, edgecolor='white', alpha=k),
                textprops=dict(size=10))
            pat.append(patches)

        #plt.legend(pat[0], df_phylum.PHYLUM, loc=2,fontsize=13,labelspacing = 0.4,
        #          bbox_to_anchor=(1.05, 1),frameon=False)

        plt.gca().set(aspect='equal')
        plt.title('Root', fontsize=10, x=0.5, y=0.465)
        plt.text(-1.8,
                 1.35,
                 'Lineage',
                 fontsize=15,
                 ha='left',
                 va='center',
                 color='black')
        #plt.title('Lineage',fontsize=20, fontweight='bold', x = -0.17, y = 1)
        #plt.text(1.1, 1.35, linaje_seleccionado, fontsize = 15, ha='left', va='center',
        #                    color='black')
        #>>>>>>>>>>>>>>>>>>>>>>>
        #### insetplot
        #ax2 = plt.axes([0.1, 0.66, 0.13, 0.14])
        ax2 = plt.axes([-0.07, 1.71, 0.17, 0.18])
        logo = [20, 20, 20, 20, 20, 20, 20, 20]
        logo_col = [
            'white', 'white', 'black', 'white', 'white', 'white', 'white',
            'white'
        ]
        logo_col1 = [
            'white', 'white', 'black', 'black', 'black', 'black', 'black',
            'black'
        ]
        radio = 0.5
        linaje = [logo, logo, logo, logo, logo]
        colores = [logo_col1, logo_col, logo_col, logo_col, logo_col]
        name_linaje = ['Phylum', 'Class', 'Order', 'Genus', 'Species']

        pat = []
        size = -.44
        pos = -.18
        for i, j, k, l in zip(linaje, colores, name_linaje, alphas):
            pos += .47
            size += .44
            ax2.pie(i,
                    radius=radio + size,
                    labels=None,
                    colors=j,
                    wedgeprops=dict(width=0.35, edgecolor='white', alpha=l),
                    textprops=dict(size=10))
            ax2.text(0.1,
                     pos,
                     k,
                     fontsize=9,
                     ha='left',
                     va='center',
                     fontweight='bold',
                     alpha=l)  #color='black'

    def barras_tax(df=DataFrame([]),
                   column=0,
                   dim=111,
                   title='',
                   row_num=10,
                   color=['#ff7f0e'],
                   size_x=8,
                   size_y=10,
                   ylabel_text='',
                   xlabel=10,
                   ylabel=10,
                   size_title=15,
                   size_bartxt=10,
                   sep=1.2):
        if len(df) == 0:
            print('Data frame sin datos')
        else:
            #plt.subplot(dim, facecolor= 'white')
            barWidth = 0.9
            if row_num == len(df):
                ejey = list(df.iloc[0:len(df), 1])
                val = max(ejey)
                ejex = list(df.iloc[0:len(df), column])
                colores = list(df.iloc[0:len(df), 2])
                borde = list(
                    np.repeat('white', len(df.iloc[0:row_num, column])))
                linea = list(np.repeat(0, len(df.iloc[0:row_num, column])))
            if row_num < len(df):
                ejey = list(df.iloc[0:row_num,
                                    1]) + [df.iloc[row_num:len(df), 1].sum()]
                val = max(ejey)
                ejex = list(df.iloc[0:row_num, column]) + ['Others']
                borde = list(
                    np.repeat('white', len(df.iloc[0:row_num,
                                                   column]))) + ['black']
                colores = list(df.iloc[0:row_num, 2]) + ['linen']
                linea = list(np.repeat(0, len(df.iloc[0:row_num,
                                                      column]))) + [1]
            if row_num > len(df):
                ejey = list(df.iloc[0:len(df), 1])
                val = max(ejey)
                ejex = list(df.iloc[0:len(df), column])
                borde = list(
                    np.repeat('white', len(df.iloc[0:row_num, column])))
                colores = list(df.iloc[0:len(df), 2])
                linea = list(np.repeat(0, len(df.iloc[0:row_num, column])))

            for i, j, k, l, m in zip(ejex, ejey, borde, colores, linea):
                plt.barh(i,
                         j,
                         color=l,
                         align='center',
                         height=0.7,
                         linewidth=m,
                         alpha=1,
                         edgecolor=k)
            plt.gca().spines['right'].set_visible(False)
            plt.gca().spines['top'].set_visible(False)
            plt.gca().spines['bottom'].set_position(('data', -0.6))
            plt.gca().spines['left'].set_visible(False)
            plt.title(title, size=size_title, loc='left')
            plt.tick_params(axis="y", color="gray")
            plt.yticks(size=size_y)

            v1 = -50
            v2 = 0
            v3 = 0
            for i in range(10000):
                v1 += 50
                v2 += 50
                v3 += 10
                if v1 <= max(list(ejey)) < v2:
                    #print(v3, v1, val, v2)
                    escala = v3

            plt.xticks(range(0, val, escala), size=size_x)  #fontweight='bold'
            plt.ylabel(ylabel_text, size=ylabel)
            plt.xlabel("Number of Proteins", size=xlabel)
            #plt.tick_params(top = 'on', bottom = 'on', right = 'on', left = 'on')
            #plt.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)

            for j, k in zip(ejey, range(0, len(ejey))):
                plt.text(j + sep,
                         k - 0.2,
                         j,
                         size=size_bartxt,
                         ha='left',
                         color='black')

    import ipywidgets as widgets
    from ipywidgets import interact, interactive, fixed, interact_manual, Button, HBox, VBox, IntSlider, Label, IntRangeSlider
    from ipywidgets import Checkbox, RadioButtons
    from ipywidgets import Button, Layout
    alfas = {
        'Lineage*': [1, 1, 1, 1, 1],
        'Phylum': [1, 0.3, 0.3, 0.3, 0.3],
        'Class': [0.3, 1, 0.3, 0.3, 0.3],
        'Order': [0.3, 0.3, 1, 0.3, 0.3],
        'Genus': [0.3, 0.3, 0.3, 1, 0.3],
        'Species': [0.3, 0.3, 0.3, 0.3, 1],
        'Gradient1*': [1, 0.85, 0.7, 0.55, 0.4],
        'Gradient2*': [0.4, 0.55, 0.7, 0.85, 1],
        'Attenuate*': [0.3, 0.3, 0.3, 0.3, 0.3],
        'None*': [0, 0, 0, 0, 0]
    }
    plotss = ['Phylum', 'Class', 'Order', 'Genus', 'Species']
    posicion_subplots = []
    n = 0.9
    while n < 2:
        n += 0.1
        posicion_subplots.append(np.around(n, 1))

    color_a6 = widgets.Dropdown(options=list(circle_colors.keys()),
                                value='Colors1',
                                description='Colors:',
                                disabled=False,
                                button_style='',
                                layout=Layout(width='20%', height='25px'))
    a6 = widgets.Dropdown(options=list(alfas.keys()),
                          description='Chart 1:',
                          value='Phylum',
                          disabled=False,
                          button_style='',
                          layout=Layout(width='20%', height='25px'))
    a61 = widgets.Dropdown(options=plotss,
                           description='Chart 2:',
                           disabled=False,
                           button_style='',
                           layout=Layout(width='20%', height='25px'))
    pos_sub1 = widgets.Dropdown(options=posicion_subplots,
                                value=1.3,
                                description='xloc1:',
                                disabled=False,
                                layout=Layout(width='15%', height='25px'))
    pos_sub2 = widgets.Dropdown(options=posicion_subplots,
                                value=1.3,
                                description='xloc2:',
                                disabled=False,
                                layout=Layout(width='15%', height='25px'))
    b6 = widgets.Dropdown(options=list(range(0, 101)),
                          value=10,
                          description='rows1:',
                          disabled=False,
                          layout=Layout(width='15%', height='25px'))
    c6 = widgets.Dropdown(options=list(range(0, 101)),
                          value=10,
                          description='rows2:',
                          disabled=False,
                          layout=Layout(width='15%', height='25px'))
    z6 = widgets.ToggleButton(value=False,
                              description='Save Chart',
                              disabled=False,
                              button_style='',
                              tooltip='Description')
    o6 = widgets.Dropdown(options=[0, 0.25, 0.5, 0.75] + list(range(0, 201)),
                          value=3,
                          description='sep1:',
                          disabled=False,
                          layout=Layout(width='15%', height='25px'))
    o61 = widgets.Dropdown(options=[0, 0.25, 0.5, 0.75] + list(range(0, 201)),
                           value=3,
                           description='sep2:',
                           disabled=False,
                           layout=Layout(width='15%', height='25px'))

    d6 = widgets.Dropdown(options=list(range(0, 51)),
                          value=8,
                          description='size_y1:',
                          disabled=False,
                          layout=Layout(width='15%', height='25px'))
    d61 = widgets.Dropdown(options=list(range(0, 51)),
                           value=8,
                           description='size_y2:',
                           disabled=False,
                           layout=Layout(width='15%', height='25px'))
    g6 = widgets.Dropdown(options=list(range(0, 51)),
                          value=8,
                          description='bartxt1:',
                          disabled=False,
                          layout=Layout(width='15%', height='25px'))
    g61 = widgets.Dropdown(options=list(range(0, 51)),
                           value=8,
                           description='bartxt2:',
                           disabled=False,
                           layout=Layout(width='15%', height='25px'))

    xxx = Button(layout=Layout(width='5%', height='25px'), disabled=True)
    xxx.style.button_color = 'white'
    yyy = Button(layout=Layout(width='94%', height='5px'), disabled=True)
    yyy.style.button_color = 'red'

    ww = widgets.HBox([color_a6, xxx, z6])
    w6 = widgets.HBox([
        a6,
        b6,
        o6,
        d6,
        g6,
        pos_sub1,
    ])
    w7 = widgets.HBox([
        a61,
        c6,
        o61,
        d61,
        g61,
        pos_sub2,
    ])
    w8 = widgets.VBox([w6, w7, yyy])

    ######

    def col(color_a6):
        tax_colors(color_list=circle_colors[color_a6], taxx=dfUniprot)

    out7 = widgets.interactive_output(col, {'color_a6': color_a6})

    def box1(a6, a61, pos_sub1, pos_sub2, b6, c6, z6, o6, o61, d6, d61, g6,
             g61):
        yetiquetas_plot1 = {
            'Lineage*': 'Phylum',
            'Phylum': 'Phylum',
            'Class': 'Class',
            'Order': 'Order',
            'Genus': 'Genus',
            'Species': 'Species',
            'Gradient1*': 'Phylum',
            'Gradient2*': 'Phylum',
            'Attenuate*': 'Phylum',
            'None*': 'Phylum'
        }
        plots1 = {
            'Lineage*': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA'),
            'Phylum': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA'),
            'Class': pd.read_csv('tax/class11.tsv', sep='\t').fillna('NA'),
            'Order': pd.read_csv('tax/order11.tsv', sep='\t').fillna('NA'),
            'Genus': pd.read_csv('tax/genus11.tsv', sep='\t').fillna('NA'),
            'Species': pd.read_csv('tax/org11.tsv', sep='\t').fillna('NA'),
            'Gradient1*': pd.read_csv('tax/phylum0.tsv',
                                      sep='\t').fillna('NA'),
            'Gradient2*': pd.read_csv('tax/phylum0.tsv',
                                      sep='\t').fillna('NA'),
            'Attenuate*': pd.read_csv('tax/phylum0.tsv',
                                      sep='\t').fillna('NA'),
            'None*': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA')
        }
        plots2 = {
            'Phylum': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA'),
            'Class': pd.read_csv('tax/class11.tsv', sep='\t').fillna('NA'),
            'Order': pd.read_csv('tax/order11.tsv', sep='\t').fillna('NA'),
            'Genus': pd.read_csv('tax/genus11.tsv', sep='\t').fillna('NA'),
            'Species': pd.read_csv('tax/org11.tsv', sep='\t').fillna('NA')
        }
        ax3 = plt.axes([pos_sub2, .97, .3, 0.55])
        ##>>>>>>>>>>> grafico circular
        ax = plt.axes([0, 1, 0.9, 1])
        circle_lineage(alphas=alfas[a6])
        ##>>>>>>>>>>> grafico 1
        #ax2 = plt.axes([pos_sub1, 1.51, .3, 0.55])
        ax2 = plt.axes([pos_sub1, 1.63, .3, 0.4])  #>>>>>>>>>>

        barras_tax(
            plots1[a6],
            #barras_tax(tax_colors(color_list = circle_colors['Spectral'])[0],
            row_num=b6,
            color=plots1[a6].iloc[0:b6, 2],
            sep=o6,
            size_y=d6,
            size_bartxt=g6,
            ylabel_text=yetiquetas_plot1[a6],
            ylabel=10)

        ##>>>>>>>>>>> grafico 2
        ax3 = plt.axes([pos_sub2, .97, .3, 0.55])

        barras_tax(
            plots2[a61],
            #barras_tax(tax_colors(color_list = circle_colors['Spectral'])[0],
            row_num=c6,
            color=plots2[a61].iloc[0:b6, 2],
            sep=o61,
            size_y=d61,
            size_bartxt=g61,
            ylabel_text=yetiquetas_plot1[a61],
            ylabel=10)

        ##>>>>>>>>>>>> save
        if z6 == True:
            import datetime
            plt.savefig('img/Lineage' +
                        datetime.datetime.now().strftime('%d.%B.%Y_%I-%M%p') +
                        '.png',
                        dpi=900,
                        bbox_inches='tight')
        else:
            pass

    out6 = widgets.interactive_output(
        box1, {
            'a6': a6,
            'a61': a61,
            'pos_sub1': pos_sub1,
            'pos_sub2': pos_sub2,
            'b6': b6,
            'c6': c6,
            'z6': z6,
            'o6': o6,
            'o61': o61,
            'd6': d6,
            'd61': d61,
            'g6': g6,
            'g61': g61
        })
    import warnings
    warnings.filterwarnings("ignore")
    return display(VBox([yyy, ww, w8, out6]))
Esempio n. 5
0
def plotData(data, labels=None, data_axis=4, expert=None, xlims=None, ylims=None, interpolate=None, smoothing=None):
    """
    This produces a line plot with confidence intervals as specified
    Uses the standard error of the mean as confidence intervals
    Args:
        data[dict] - Dict of multi_dim array of N+1xM array of columns where the 
            second column is the x-axis, and every other column is a dataset 
        labels[list] - String list of [x-axis, y-axis, title]
        data_axis[int] - Column to plot against the x-axis
        expert[scalar] - Value that the expert/demonstrator performed at (horiz line on plot)
        xlims/ylims - (min, max) values for the axes
        interpolate[list] - Name of the experiments to interpolate points
        smoothing[dict] - Name and value pairs to perform smoothing over the data before plotting
    """
    assert len(data.keys()) <= 8 # Only 8 colors available in this set, don't expect this to be a problem

    # Set up the plot
    plt.figure(figsize=(12,9))
    
    # Remove the plot frame lines
    ax = plt.subplot(111)
    ax.spines["top"].set_visible(False)
    ax.spines["right"].set_visible(False)
    
    # Set the axis ticks to only show up on the bottom and left of plot
    ax.get_xaxis().tick_bottom()
    ax.get_yaxis().tick_left()
    
    # Limit the range of the plot to the data
    if xlims != None:
        plt.xlim(xlims[0], xlims[1])
    if ylims != None:
        plt.ylim(ylims[0], ylims[1])
    
    # Increase axis tick marks
    # plt.xticks(range(0, 100, 10), fontsize=14)
    # plt.yticks(range(-60, 0, 10), fontsize=14)
    
    ax.tick_params(labelsize=16)
    
    # Axis and title labels with increased size
    if labels == None:
        labels = ['X-Axis', 'Y-Axis', 'Title']
    plt.xlabel(labels[0], fontsize=24)
    plt.ylabel(labels[1], fontsize=24)
    # plt.title(labels[2], fontsize=22) #### TODO WHEN MAKING SLIDE DECK
    
    # Show a horizontal line with the expert's performance if available
    if expert is not None:
        plt.hlines(expert, xmin=0, xmax=20000, colors='#737373', 
                label='Expert', linewidths=3, linestyles='dashdot') #linestyles : [‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’],
    
    # Pastel2 and Dark2 should be the colormaps used for confidence and mean resp.
    cmap = ['Dark2', 'Pastel2'] 
    
    # Iterate over the recorded datasets
    i = 0.0
    for name, values in data.items():
        if interpolate is not None and name in interpolate:
            values = interpolateData(values, data_axis=data_axis)
        if smoothing is not None and name in smoothing:
            for j in range(values.shape[2]):
                values[:,data_axis,j] = smooth(values[:,data_axis,j], window_len=smoothing[name])
        x_axis, means, bands = formatConfidenceData(values, bound='std', data_axis=data_axis)
        plt.plot(x_axis, means, lw=2, label=name, color=cm.Dark2(i)) 
        plt.fill_between(x_axis, means - bands, means + bands, color=cm.Pastel2(i))
        i += 0.126 # Change color
        
    plt.legend(loc=4, prop={'size':24}) # There are up to 10 positions, 0 is best, 1 upper right, 2 top left, 3, 4 lower right
    plt.show()
Esempio n. 6
0
ax = ds_r.iloc[:, :-1].plot.box(figsize=(12, 6),
                                title="Tempos por função (grpc remoto)")
ax.set_ylabel("Tempo em segundos")
plt.xticks(rotation=45)
ax.set_xlabel("Função")

# barplot mean
fig, ax = plt.subplots(figsize=(12, 6))
error_config = {'ecolor': '0.3'}

ds = ds_rpyc_r
for i, col in enumerate(ds_r.columns):
    if col == 'euclidean_arg': continue
    ax.barh(i,
            ds[col].mean(),
            color=cm.Pastel2(i),
            xerr=ds[col].std(),
            error_kw=error_config)
    ax.text(ds[col].mean() * .3, i, str(round(ds[col].mean(), 8)))

ax.set_yticklabels(ds_r.columns[:-1])
ax.set_yticks(np.arange(len(ds_r.columns)) + .2)
ax.set_title('Tempo médio por função (rpyc remoto)')
ax.set_xlabel("Tempo em segundos")
ax.set_ylabel("Função")

# scatter for latency
fig, ax = plt.subplots(figsize=(12, 6))
ax.scatter(x=np.arange(len(ds_rpyc)),
           y=ds_rpyc['int_arg'],
           label='local',
Esempio n. 7
0
    def plot_bar(self, fig, datafile, xnames):
        f = open(datafile)
        #f = open("plot_exec_time.txt")

        barGroups = dict()
        locations = list()

        barNameOrder = list()

        xnameLookup = dict()

        hasErr = False

        confSplit = ';'

        for line in f:
            if line[0] == '#':
                continue
            (x, y, text) = line.split('\t')
            yval = float(y.split(confSplit)[0])
            yerr = 0.0

            if confSplit in y:
                hasErr = True
                s = y.split(confSplit)
                yerr = float(s[1])

            text = text.strip()
            if text not in barNameOrder:
                barNameOrder.append(text)
            if text not in barGroups:
                barGroups[text] = dict()
            if x not in barGroups[text]:
                barGroups[text][x] = dict()

            barGroups[text][x]['bar'] = yval
            barGroups[text][x]['err'] = yerr

            if x not in xnameLookup:
                i = len(locations)
                locations.append(i)
                xnameLookup[x] = i

        width = 0.5 / len(barGroups)

        locations = sorted(locations)

        loc = np.arange(len(locations))
        pos = 0
        for l in locations:
            loc[pos] = int(l)
            pos += 1

        ax = fig.add_subplot(111)

        numPlots = 0
        barLen = float(len(barGroups))
        rects = list()
        names = list()

        cur_hatch = 0
        for b in barNameOrder:
            print b
            values = barGroups[b]

            barPlot = list()
            barErrPlot = list()

            for l in locations:
                found = False
                for k in xnameLookup:
                    if xnameLookup[k] == l and k in values:
                        #				  if l in values and values[l] > 0:
                        barPlot.append(values[k]['bar'])
                        barErrPlot.append(values[k]['err'])
                        found = True
                if not found:
                    barPlot.append(0.0)
                    barErrPlot.append(0.0)

            ax.set_yscale('linear')
            if hasErr:
                rect = ax.bar(loc + (numPlots * width),
                              barPlot,
                              width,
                              color=cm.Pastel2(numPlots / barLen, 1),
                              hatch=self.hatches[cur_hatch %
                                                 (len(self.hatches))],
                              yerr=barErrPlot,
                              ecolor='black',
                              capsize=5)
            else:
                rect = ax.bar(loc + (numPlots * width),
                              barPlot,
                              width,
                              color=cm.Pastel2(numPlots / barLen, 1),
                              hatch=self.hatches[cur_hatch %
                                                 (len(self.hatches))])
            cur_hatch += 1

            rects.append(rect[0])
            names.append(b)
            ax.grid(which='major', color='0.65', linestyle='--')

            numPlots += 1
            #[line.set_zorder(3) for line in ax.lines]
            ax.set_axisbelow(True)

        ax.set_ylabel('Execution Time [minutes]')
        ax.set_xticks(loc + 0.2)

        ax.yaxis.set_major_formatter(ticker.FuncFormatter(self.format_tiny))

        labels = sorted(xnameLookup, key=lambda x: xnameLookup[x])
        ax.set_xticklabels((labels), rotation=0)

        ax.legend(rects, names, 'best')
        return [ax]
Esempio n. 8
0
    def plot_multi(self, fig, datafile, line_style, xformat, legendStyle, sort,
                   loc, markeveryInp):
        f = open(datafile)

        hasErrorBar = False

        hash = dict()

        sub_plot_num = 111
        for line in f:
            line = line.split('\t')

            if (len(line) > 3):
                sub_plot_num = int(line[3].strip())

            p_name = line[2].strip()
            #if not hash.has_key(sub_plot_num):
            if not sub_plot_num in hash:  # Does not work in Python3
                hash[sub_plot_num] = dict()
            if not p_name in hash[sub_plot_num]:
                x = list()
                y = list()
                err = list()
                hash[sub_plot_num][p_name] = (x, y, err)

            hash[sub_plot_num][p_name][0].append(line[0])

            if len(line[1].split(';')) == 1:  # Check for error bars
                hash[sub_plot_num][p_name][1].append(line[1])
                hash[sub_plot_num][p_name][2].append(0)  #

            else:
                hasErrorBar = True
                hash[sub_plot_num][p_name][1].append(
                    line[1].split(';')[0])  # Append Y value
                hash[sub_plot_num][p_name][2].append(
                    line[1].split(';')[1])  # Append Error Value

        f.close()

        subplots = list()
        ax1 = 0
        ticks = list()
        sorted_hash = sorted(iter(hash.keys()))
        for sub_plot_num in sorted_hash:
            if (ax1 == 0):
                ax = fig.add_subplot(sub_plot_num)
                ax1 = ax
            else:
                ax = fig.add_subplot(sub_plot_num, sharex=ax1)
            subplots.append(ax)
            plots = list()
            if sort == "int":
                sorted_names = map(
                    lambda x: str(x),
                    sorted(map(lambda x: int(x), hash[sub_plot_num])))
            else:
                sorted_names = sorted(hash[sub_plot_num])
#			for p_name in hash[sub_plot_num]:
            i = 0
            cm_len = float(len(sorted_names))
            y_valsStacked = list()
            longestStacked = 0
            for p_name in sorted_names:
                if xformat == 'cdf':
                    y_vals = self.calc_cdf(hash[sub_plot_num][p_name][1])
                    x_vals = hash[sub_plot_num][p_name][0]
                    hash[sub_plot_num][p_name][0][:0] = [0]  #prepend 0
                elif xformat == 'ccdf':
                    y_vals = self.calc_ccdf(hash[sub_plot_num][p_name][1])
                    x_vals = hash[sub_plot_num][p_name][0]
                    #hash[sub_plot_num][p_name][0].append(x_vals[-1])
                    #x_vals = hash[sub_plot_num][p_name][0]
                elif xformat == 'eccdf':  # ECCDF has to update the X values as well.
                    x_vals, y_vals = self.ecdf(hash[sub_plot_num][p_name][0],
                                               hash[sub_plot_num][p_name][1])
                else:
                    if hasErrorBar:
                        y_vals = [
                            float(a) for a in hash[sub_plot_num][p_name][1]
                        ]
                        y_err = [
                            float(a) for a in hash[sub_plot_num][p_name][2]
                        ]

                        y_err_high = [
                            float(a) + float(b)
                            for a, b in zip(hash[sub_plot_num][p_name][1],
                                            hash[sub_plot_num][p_name][2])
                        ]
                        y_err_low = [
                            float(a) - float(b)
                            for a, b in zip(hash[sub_plot_num][p_name][1],
                                            hash[sub_plot_num][p_name][2])
                        ]
                    else:

                        y_vals = hash[sub_plot_num][p_name][1]
                    x_vals = hash[sub_plot_num][p_name][0]

                if line_style == 'multi':
                    dots = ".x+"
                    ax.plot(x_vals,
                            y_vals,
                            dots[i % len(dots)],
                            c=cm.hsv(i / cm_len, 1))
                elif line_style == 'multi-':
                    dots = ["-v", "-x", "-o"]
                    if hasErrorBar:
                        plt.errorbar(x_vals,
                                     y_vals,
                                     fmt=dots[i % len(dots)],
                                     c=cm.hsv(i / cm_len, 1),
                                     yerr=y_err)
                    else:
                        ax.plot(x_vals,
                                y_vals,
                                dots[i % len(dots)],
                                c=cm.hsv(i / cm_len, 1))
                elif line_style == 'multi--':
                    dots = ["--v", "--x", "--o"]
                    if hasErrorBar:
                        #plt.errorbar(x_vals, y_vals, fmt=dots[i%len(dots)], c=cm.gnuplot(i/cm_len,1), yerr=y_err)
                        plt.errorbar(x_vals,
                                     y_vals,
                                     fmt=dots[i % len(dots)],
                                     yerr=y_err)
                    else:
                        ax.plot(
                            x_vals,
                            y_vals,
                            dots[i % len(dots)],
                            c=cm.gnuplot(i / cm_len, 1),
                        )

                elif line_style == 'multismall-':
                    dots = ["-", "-+", "-x"]
                    ax.plot(x_vals,
                            y_vals,
                            dots[i % len(dots)],
                            c=cm.hsv(i / cm_len, 1))
                elif line_style == 'multismall':
                    dots = [".", "+", "x"]
                    ax.plot(x_vals,
                            y_vals,
                            dots[i % len(dots)],
                            c=cm.hsv(i / cm_len, 1))
                elif line_style == 'bnw':
                    dots = ["h", "+", "x", "d", "v", "o", "D", "."]
                    ax.plot(x_vals, y_vals, dots[i % len(dots)])
                elif line_style == 'bnw-':
                    dots = ["-h", "-+", "-x", "-d", "-v", "-o", "-D", "-."]
                    ax.plot(x_vals,
                            y_vals,
                            dots[i % len(dots)],
                            markevery=int(markeveryInp))
                    #ax.plot(x_vals, y_vals, dots[i%len(dots)])
                elif xformat == 'stack':
                    y = np.array(y_vals, dtype=float)
                    y_valsStacked.append(y)
                    if longestStacked < len(y):
                        longestX = x_vals
                    longestStacked = max(longestStacked, len(y))
                elif xformat == 'fill':
                    ax.fill(x_vals,
                            y_vals,
                            line_style,
                            edgecolor='black',
                            hatch=self.hatches[i % len(self.hatches)],
                            color=cm.Pastel2(i / cm_len, 1))
                else:
                    if hasErrorBar:
                        plt.errorbar(x_vals,
                                     y_vals,
                                     linestyle=line_style,
                                     yerr=y_err)

                    else:
                        ax.plot(x_vals, y_vals, line_style)

                plots.append(p_name)
                i += 1

            if xformat == 'stack':
                print longestStacked
                #ys = [np.array(y, dtype=float).resize(longestStacked) for y in y_valsStacked]
                stacks = list()
                y_cnt = 0
                for y in y_valsStacked:
                    y = np.copy(y)
                    y.resize(longestStacked)
                    print y
                    stacks.append(y)
                    y_cnt += 1
#				ys = [np.array(y, dtype=float) for y in y_valsStacked]
#				ys = [y.resize(longestStacked) for y in ys]
                ax.stackplot(np.array(longestX, dtype=float),
                             *stacks,
                             baseline='wiggle')

            if legendStyle == 'none':
                pass
            elif (legendStyle == 'single'
                  or legendStyle == 'single-outside') and i > 1:
                pass
            elif legendStyle == 'outside':
                leg = ax.legend(plots,
                                bbox_to_anchor=(1.01, 1),
                                loc=2,
                                borderaxespad=0.5)
            elif legendStyle == 'below':
                ax.legend(plots,
                          loc='upper center',
                          bbox_to_anchor=(0.5, -0.15),
                          fancybox=True,
                          shadow=True,
                          ncol=2)
            else:
                try:
                    loc = int(loc)
                except:
                    loc = loc
                finally:
                    leg = ax.legend(plots, loc=loc)

            ax.grid(True)

        if legendStyle == 'single':
            leg = subplots[0].legend(plots, 'best')
        elif legendStyle == 'single-outside':
            leg = subplots[0].legend(plots,
                                     bbox_to_anchor=(1.01, 1),
                                     loc=2,
                                     borderaxespad=0.5)

        if xformat == 'time':
            ax.xaxis.set_major_formatter(ticker.FuncFormatter(
                self.format_time))
            fig.autofmt_xdate()
        elif xformat == 'date':
            ax.xaxis.set_major_formatter(ticker.FuncFormatter(
                self.format_date))
            fig.autofmt_xdate()
        elif xformat == 'days':
            min_time = int(min(x))
            self.start_day = min_time - min_time % 86400
            ax.xaxis.set_major_formatter(ticker.FuncFormatter(
                self.format_days))
        elif xformat == 'tiny':
            ax.xaxis.set_major_formatter(ticker.FuncFormatter(
                self.format_tiny))
            ax.yaxis.set_major_formatter(ticker.FuncFormatter(
                self.format_tiny))
            #fig.autofmt_xdate()
        elif xformat == 'dict':
            ax.xaxis.set_major_formatter(ticker.FuncFormatter(
                self.format_dict))
            fig.autofmt_xdate()

        return subplots