Example #1
0
def binned_cummulative(cummulative_per_country, bins=4, show=False):
    binned_cum_per_country = dict((option,{}) for option in options)
    for option in options:
        for country, samples in cummulative_per_country[option].iteritems():
            hist = np.histogram(samples,bins,weights=samples)[0] / np.histogram(samples,bins)[0]
            binned_cum_per_country[option][country] = sorted(hist)

    f, ax = plt.subplots(2)
    ticks_labels = cummulative_per_country['absolute'].keys()
    ticks_positions = [[] for i in range(len(ticks_labels))]

    for subplot, option in enumerate(options):
        width = 0.75
        ind = 0
        gap = 1

        for i, (country, samples) in enumerate(binned_cum_per_country[option].iteritems()):
            for sample in samples:
                ax[subplot].bar(ind+i*gap, sample, width, color=cm.Vega20(i+1))
                ticks_positions[i].append(ind+i*gap)
                ind += 1

        centers = [(ticks_positions[i][0] + ticks_positions[i][-1])/2 for i in range(len(ticks_labels))]
        ax[subplot].set_xticks(centers)
        ax[subplot].set_xticklabels(ticks_labels)

    ax[0].set_title('Normalized binned amount of resistant bacterias per sample per country')
    ax[1].set_title('Absolute binned number of resistant bacterias per sample per country')
    plt.tight_layout()

    if show:
        plt.show()
Example #2
0
def cummulative(cummulative_per_country, show=False):
    f, ax = plt.subplots(2)
    ticks_labels = cummulative_per_country['absolute'].keys()
    ticks_positions = [[] for i in range(len(ticks_labels))]

    for subplot, option in enumerate(options):
        width = 0.75
        ind = 0
        gap = 5

        for i, (country, samples) in enumerate(cummulative_per_country[option].iteritems()):
            for j, sample in enumerate(samples):
                ax[subplot].bar(ind+i*gap, sample, width, color=cm.Vega20(i+1))
                ticks_positions[i].append(ind+i*gap)
                ind += 1

        centers = [(ticks_positions[i][0] + ticks_positions[i][-1])/2 for i in range(len(ticks_labels))]
        ax[subplot].set_xticks(centers)
        ax[subplot].set_xticklabels(ticks_labels)

    ax[0].set_title('Normalized amount of resistant bacterias per sample per country')
    ax[1].set_title('Absolute number of resistant bacterias per sample per country')
    plt.tight_layout()

    if show:
        plt.show()
Example #3
0
web_get001txtFg = False  # @zt_web.web_get001txtFg

#-----bs4.findall
bs_get_ktag_kstr = ''

#--colors
#10,prism,brg,dark2,hsv,jet
#10,,hot,Vega10,Vega20
cors_brg = cm.brg(np.linspace(0, 1, 10))
cors_hot = cm.hot(np.linspace(0, 1, 10))
cors_hsv = cm.hsv(np.linspace(0, 1, 10))
cors_jet = cm.jet(np.linspace(0, 1, 10))
cors_prism = cm.prism(np.linspace(0, 1, 10))
cors_Dark2 = cm.Dark2(np.linspace(0, 1, 10))
cors_Vega10 = cm.Vega10(np.linspace(0, 1, 10))
cors_Vega20 = cm.Vega20(np.linspace(0, 1, 10))

#------str.xxx
sgnSP4 = '    '
sgnSP8 = sgnSP4 + sgnSP4

#-----FN.xxx
logFN = ''

#--------------dir
#
rdat0 = 'zDat/'
rdatCN = rdat0 + "cn/day/"
rdatCNX = rdat0 + "cn/xday/"
rdatInx = rdat0 + "inx/"
rdatMin0 = rdat0 + "min/"
Example #4
0

for country, drugs in drugs_per_country.iteritems():
    averages[country] = np.mean(drugs)

ticks_labels = [country for country, avg in averages.iteritems()]
ticks_positions = [[] for i in range(len(ticks_labels))]
# [country_drug_use_df['country_2letter'].ix[i] for i in range(9)]
f, ax = plt.subplots(1)
width = 0.75
ind = 0
gap = 0.5

for i, (country, avg) in enumerate(averages.iteritems()):
    print country, avg
    ax.bar(ind+i*gap, avg, width, color=cm.Vega20(i+1))
    ticks_positions[i].append(ind+i*gap)
    ind += 1

centers = [(ticks_positions[i][0] + ticks_positions[i][-1])/2 for i in range(len(ticks_labels))]
ax.set_xticks(centers)
ax.set_xticklabels(ticks_labels)

ax.set_title('Average drugs use per country')
plt.tight_layout()
plt.show()

    if show:
        plt.show()

Example #5
0
 def fill_square(x, y, s):
     plt.fill([x, x, x + s, x + s], [y, y + s, y + s, y],
              color=colormap.Vega20(rand()))