Ejemplo n.º 1
0
def method_boxplot(data,
                   xlabels,
                   line_color=default_color,
                   med_color=None,
                   legend=None,
                   x_offset=0.0):
    if not med_color:
        med_color = line_color
    ax.grid(axis='x', color='0.9', linestyle='-', linewidth=0.2)
    ax.set_axisbelow(True)
    ppl.boxplot(ax,
                data,
                positions=np.array(range(len(xlabels))) - x_offset,
                yticklabels=xlabels.tolist(),
                linewidth=0.3,
                widths=0.2,
                show_caps=False,
                sym='',
                vert=False,
                line_color=line_color,
                med_color=med_color)
    plt.xlabel('% cases used')
    ax.set_yticks(np.array(range(len(xlabels))))
    ax.set_yticklabels(xlabels, fontsize=6)
    spines_to_remove = ['top', 'right', 'left']
    for spine in spines_to_remove:
        ax.spines[spine].set_visible(False)

    if legend:
        rect = legend.get_frame()
        rect.set_facecolor(light_grey)
        rect.set_linewidth(0.0)
def boxplot(ax, data, xticklabels, ylabel):
  if isinstance(data, collections.Iterable):
    ppl.boxplot(ax, data, notch=True, xticklabels=xticklabels, sym="", vert=False)
    ax.set_ylabel(ylabel)
  else:
    sys.stderr.write("data has to be iterable\n")
    sys.exit(1)
  return ax
Ejemplo n.º 3
0
def test_boxplot():
    # Set the random seed for consistency
    np.random.seed(10)

    data = np.random.randn(8, 4)
    labels = ['A', 'B', 'C', 'D']

    fig, ax = plt.subplots()
    ppl.boxplot(ax, data, xticklabels=labels)
Ejemplo n.º 4
0
def boxplotEllipseVsExclReg(type_header, type_table, config, instanceType, figName = None):
  
  if config not in type_table:
    raise Exception("Config \""+config+"\" not found!")
  if instanceType not in type_table[config]:
    raise Exception("Instance type \""+instanceType+"\" not found!")
  
  fig, ax = plt.subplots(1)

  data = []
  for size in sorted(type_table[config][instanceType].iterkeys()):
    byEllipse = np.array(map(float, type_table[config][instanceType][size]["excludedByEllipse"]))
    exclugReg = np.array(map(float, type_table[config][instanceType][size]["exclusionReg"]))

    blockedEdgesPropInc = ((byEllipse - exclugReg) / exclugReg) * 100.0

    if size == 70:
      print "box:", byEllipse.mean(), exclugReg.mean()

    data.append(blockedEdgesPropInc)

  ret = ppl.boxplot(ax, data, xticklabels=map(str, sorted(type_table[config][instanceType].iterkeys())),
                    widths=0.3, showmeans=True, meanprops=meanprops)

  ax.set_xlabel(u'# Pontos')
  ax.set_ylabel(u'Incremento % Arestas Bloqueadas')

  if figName != None:
    fig.savefig(figName, bbox_inches='tight')
Ejemplo n.º 5
0
def boxplotFixedPaths(type_header, type_table, config, instanceType, figName = None):
  
  if config not in type_table:
    raise Exception("Config \""+config+"\" not found!")
  if instanceType not in type_table[config]:
    raise Exception("Instance type \""+instanceType+"\" not found!")
  
  fig, ax = plt.subplots(1)

  data = []
  for size in sorted(type_table[config][instanceType].iterkeys()):
    fixedpaths = np.array(map(int, type_table[config][instanceType][size]["preproc.fixedPaths"]))
    nPaths = (size*(size-1))/2.0
    fixedPathsProp = fixedpaths/nPaths * 100.0

    data.append(fixedPathsProp)

  ret = ppl.boxplot(ax, data, xticklabels=map(str, sorted(type_table[config][instanceType].iterkeys())),
                    widths=0.3, showmeans=True, meanprops=meanprops)

  ax.set_xlabel(u'# Pontos')
  ax.set_ylabel(u'% Caminhos Fixados')

  if figName != None:
    fig.savefig(figName, bbox_inches='tight')
Ejemplo n.º 6
0
def boxplotFixedEdgesSols(type_header, type_table, config, instanceType,
                          solsPath, solsExt, figName = None):
  
  if config not in type_table:
    raise Exception("Config \""+config+"\" not found!")
  if instanceType not in type_table[config]:
    raise Exception("Instance type \""+instanceType+"\" not found!")
  
  fig, ax = plt.subplots(1)

  data = []
  for size in sorted(type_table[config][instanceType].iterkeys()):
    fixedEdges = np.array(map(int, type_table[config][instanceType][size]["preproc.fixedEdges"]))
    instanceNumbers = np.array(type_table[config][instanceType][size]["instanceNumber"])

    fixedEdgesProp = []

    for fEdges, instanceNumber in zip(fixedEdges, instanceNumbers):
      instanceName = "%s_%03d_%02d%s" % (instanceType, size, instanceNumber, solsExt)
      solEdges = getNEdges(os.path.join(solsPath, instanceName))

      fEdgesProp = float(fEdges)/float(solEdges) * 100.0
      fixedEdgesProp.append(fEdgesProp)

    data.append(fixedEdgesProp)

  ret = ppl.boxplot(ax, data, xticklabels=map(str, sorted(type_table[config][instanceType].iterkeys())),
                    widths=0.3, showmeans=True, meanprops=meanprops)

  ax.set_xlabel(u'# Pontos')
  ax.set_ylabel(u'% Arestas Fixadas')

  if figName != None:
    fig.savefig(figName, bbox_inches='tight')
def method_boxplot(data,xlabels, line_color=default_color,
                   med_color=None, legend=None, x_offset=0.0):
    if not med_color:
        med_color=line_color
    ax.grid(axis='x', color='0.9', linestyle='-', linewidth=0.2)
    ax.set_axisbelow(True)
    ppl.boxplot(ax,data, positions=np.array(range(len(xlabels)))-x_offset,
                yticklabels=xlabels.tolist(),linewidth=0.3,
                widths=0.2,show_caps=False,sym='',vert=False,
                line_color=line_color, med_color=med_color)
    plt.xlabel('% cases used')
    ax.set_yticks(np.array(range(len(xlabels))))
    ax.set_yticklabels(xlabels,fontsize=6)
    spines_to_remove = ['top', 'right','left']
    for spine in spines_to_remove:
        ax.spines[spine].set_visible(False)
    
    if legend:
        rect = legend.get_frame()
        rect.set_facecolor(light_grey)
        rect.set_linewidth(0.0)
Ejemplo n.º 8
0
def boxplotFixedEdgesSols(type_header,
                          type_table,
                          config,
                          instanceType,
                          solsPath,
                          solsExt,
                          figName=None):

    if config not in type_table:
        raise Exception("Config \"" + config + "\" not found!")
    if instanceType not in type_table[config]:
        raise Exception("Instance type \"" + instanceType + "\" not found!")

    fig, ax = plt.subplots(1)

    data = []
    for size in sorted(type_table[config][instanceType].iterkeys()):
        fixedEdges = np.array(
            map(int,
                type_table[config][instanceType][size]["preproc.fixedEdges"]))
        instanceNumbers = np.array(
            type_table[config][instanceType][size]["instanceNumber"])

        fixedEdgesProp = []

        for fEdges, instanceNumber in zip(fixedEdges, instanceNumbers):
            instanceName = "%s_%03d_%02d%s" % (instanceType, size,
                                               instanceNumber, solsExt)
            solEdges = getNEdges(os.path.join(solsPath, instanceName))

            fEdgesProp = float(fEdges) / float(solEdges) * 100.0
            fixedEdgesProp.append(fEdgesProp)

        data.append(fixedEdgesProp)

    ret = ppl.boxplot(ax,
                      data,
                      xticklabels=map(
                          str,
                          sorted(type_table[config][instanceType].iterkeys())),
                      widths=0.3,
                      showmeans=True,
                      meanprops=meanprops)

    ax.set_xlabel(u'# Pontos')
    ax.set_ylabel(u'% Arestas Fixadas')

    if figName != None:
        fig.savefig(figName, bbox_inches='tight')
Ejemplo n.º 9
0
def boxplotEllipseVsExclReg(type_header,
                            type_table,
                            config,
                            instanceType,
                            figName=None):

    if config not in type_table:
        raise Exception("Config \"" + config + "\" not found!")
    if instanceType not in type_table[config]:
        raise Exception("Instance type \"" + instanceType + "\" not found!")

    fig, ax = plt.subplots(1)

    data = []
    for size in sorted(type_table[config][instanceType].iterkeys()):
        byEllipse = np.array(
            map(float,
                type_table[config][instanceType][size]["excludedByEllipse"]))
        exclugReg = np.array(
            map(float, type_table[config][instanceType][size]["exclusionReg"]))

        blockedEdgesPropInc = ((byEllipse - exclugReg) / exclugReg) * 100.0

        if size == 70:
            print "box:", byEllipse.mean(), exclugReg.mean()

        data.append(blockedEdgesPropInc)

    ret = ppl.boxplot(ax,
                      data,
                      xticklabels=map(
                          str,
                          sorted(type_table[config][instanceType].iterkeys())),
                      widths=0.3,
                      showmeans=True,
                      meanprops=meanprops)

    ax.set_xlabel(u'# Pontos')
    ax.set_ylabel(u'Incremento % Arestas Bloqueadas')

    if figName != None:
        fig.savefig(figName, bbox_inches='tight')
Ejemplo n.º 10
0
def boxplotFixedPaths(type_header,
                      type_table,
                      config,
                      instanceType,
                      figName=None):

    if config not in type_table:
        raise Exception("Config \"" + config + "\" not found!")
    if instanceType not in type_table[config]:
        raise Exception("Instance type \"" + instanceType + "\" not found!")

    fig, ax = plt.subplots(1)

    data = []
    for size in sorted(type_table[config][instanceType].iterkeys()):
        fixedpaths = np.array(
            map(int,
                type_table[config][instanceType][size]["preproc.fixedPaths"]))
        nPaths = (size * (size - 1)) / 2.0
        fixedPathsProp = fixedpaths / nPaths * 100.0

        data.append(fixedPathsProp)

    ret = ppl.boxplot(ax,
                      data,
                      xticklabels=map(
                          str,
                          sorted(type_table[config][instanceType].iterkeys())),
                      widths=0.3,
                      showmeans=True,
                      meanprops=meanprops)

    ax.set_xlabel(u'# Pontos')
    ax.set_ylabel(u'% Caminhos Fixados')

    if figName != None:
        fig.savefig(figName, bbox_inches='tight')
Ejemplo n.º 11
0
# Creates a Box plot of the Clean Height Data and the Raw Height Data
plt.figure(4)

labels = ['Height (Clean)', 'Height (Raw)']

dataHeight = pd.DataFrame({
    'Height (Clean)': cleanHeight['Height'],
    'Height (Raw)': studentData['Height']
})

dataHeightArray = np.array(dataHeight)

#print dataHeightArray

ppl.boxplot(dataHeightArray, xticklabels=labels, fontsize=16)

newAx = np.arange(0, 80, 5)

plt.yticks(newAx)

plt.ylabel('Height (inches)', fontsize=16)
plt.title(s="Heights of Students", fontsize=20)

plt.show()

#Subset of Data that contains just the Gender Columns and Hair Dyed Columns
studentHairDye = studentData.loc[:, ['Gender', 'Hair dyed?']]

#Gets rid of the Missing values in the Hair Dyed Subset (the subset object called studentHairDye) )
Ejemplo n.º 12
0
                for x in range(count):
                    data[locat].append(value)

print("data")
for i in data:
    print(i[:10])
print("data")

#np.random.seed(10)

#data = np.random.randn(8, 4)

u_labels = ['1e-7 mid','1e-7 end','1e-6 mid','1e-6 end','1e-5 mid','1e-5 end','1e-4 mid','1e-4 end','0.001 mid','0.001 end','0.005 mid','0.005 end','0.01 mid','0.01 end',\
        '0.05 mid', '0.05 end','0.1 mid','0.1 end']

fig, ax = plt.subplots()

ax.set_xticklabels(u_labels)
ax.set_xticks(u_labels)
ax.set_xlabel('Initial Mutation Rates', fontsize=9)
ax.set_ylabel('End Proliferation Rates', fontsize=9)
i = 0
print(ax.get_xticklabels())
ppl.boxplot(ax, data)  #,xticklabels=u_labels)
plt.title("Distribution of End Proliferation Rates by Initial Mutation Rate",
          fontsize=9)
fig.savefig(opt.output + '_boxplot.png')
print(opt.output + "DONE")
#ppl.hist(ax,data)
#fig.savefig('histogram_prettyplotlib_default.png')
Ejemplo n.º 13
0
	weekday = calendar.weekday(date.year, date.month, date.day)
	if (weekday not in weekdaySteps.keys()):
		weekdaySteps[weekday] = []
	weekdaySteps[weekday].append(entry[1])
	if (weekday not in weekdayFloors.keys()):
		weekdayFloors[weekday] = []
	weekdayFloors[weekday].append(entry[2])

reformattedData = np.asarray([[weekdaySteps[firstThing][secondThing] for firstThing in range(7)] for secondThing in range(51)])

xLabels = ["Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays", "Sundays"]

fig2 = plt.figure(figsize=(14,8))
ax2 = fig2.add_subplot(111)

ppl.boxplot(ax2, reformattedData, xticklabels=xLabels)
# ax2.xaxis.set_ticklabels(xLabels)
saveAllTheFiles(fig2, "fitbit-per_weekday--boxplot")

averages = [np.average(weekdaySteps[day]) for day in weekdaySteps] # np.std(weekdaySteps[0])
stdDeviations = [np.std(weekdaySteps[day]) for day in weekdaySteps]
currentColor = next(color_cycle)
currentColor = next(color_cycle)
fig3 = plt.figure(figsize=(14,8))
ax3 = fig3.add_subplot(111)
ax3.errorbar(range(1,8), averages, yerr=stdDeviations, color=currentColor, fmt='o', markeredgecolor=currentColor, elinewidth=1)
ax3.xaxis.set_ticks(range(1,8))
ax3.xaxis.set_ticklabels(xLabels)
ax3.set_xlim(left=0.5, right=7.5)
ax3.set_ylim(bottom=0, top=35000)
saveAllTheFiles(fig3, "fitbit-per_weekday--mean")
Ejemplo n.º 14
0
params = {
    'axes.labelsize': 8,
    'font.size': 8,
    'legend.fontsize': 10,
    'xtick.labelsize': 10,
    'ytick.labelsize': 10,
    'text.usetex': False,
    'figure.figsize': [2.5, 4.5]
}
rcParams.update(params)

def load(dir):
    f_list = glob.glob(dir + '/*/*/bestfit.dat')
    num_lines = sum(1 for line in open(f_list[0]))
    i = 0;
    data = np.zeros((len(f_list), num_lines)) 
    for f in f_list:
        data[i, :] = np.loadtxt(f)[:,1]
        i += 1
    return data

data_low_mut = load('data/low_mut')
data_high_mut = load('data/high_mut')
low_mut_100 = data_low_mut[:, 100]
high_mut_100 =  data_high_mut[:, 100]


fig, ax = plt.subplots()
ppl.boxplot(ax, [low_mut_100, high_mut_100])

fig.savefig('boxplot_prettyplotlib_default.png')
Ejemplo n.º 15
0
import prettyplotlib as ppl
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(10)

data = np.random.randn(8, 4)
labels = ['A', 'B', 'C', 'D']

fig, ax = plt.subplots()
ppl.boxplot(ax, data, xticklabels=labels)
fig.savefig('boxplot_prettyplotlib_default.png')
####### End of code section that creates HUB food opinion graph based on CLEAN data ######


# Creates a Box plot of the Clean Height Data and the Raw Height Data
plt.figure(4)

labels = ['Height (Clean)','Height (Raw)']

dataHeight = pd.DataFrame({'Height (Clean)': cleanHeight['Height'],'Height (Raw)': studentData['Height']})

dataHeightArray = np.array(dataHeight)

#print dataHeightArray

ppl.boxplot(dataHeightArray, xticklabels= labels,fontsize= 16)



newAx = np.arange(0,80,5)

plt.yticks(newAx)

plt.ylabel('Height (inches)',fontsize = 16)
plt.title(s = "Heights of Students",fontsize = 20)



plt.show()

#Subset of Data that contains just the Gender Columns and Hair Dyed Columns