Ejemplo n.º 1
0
 def onClick(event):
     global hp, base
     if event.inaxes == hp.axes and event.button == 1:
         # left click
         for path in hp.wedges:
             cont, ind = hp.wedges[path].contains(event)
             if cont:
                 path = Path(base[:] + path[:])
                 data = {
                     p[len(path) - 1:]: time
                     for p, time in dataAll.items() if p.startswith(path)
                 }
                 ax.clear()
                 hp = HPie(data, ax)
                 hp.plot(setup_axes=True, interactive=True)
                 ax.figure.canvas.draw_idle()
                 base = Path(path[:-1])
                 break
     elif event.button == 3:
         # right click
         if len(base) > 0:
             path = base
             data = {
                 p[len(path) - 1:]: time
                 for p, time in dataAll.items() if p.startswith(path)
             }
         else:
             path = Path([])
             data = dataAll
         ax.clear()
         hp = HPie(data, ax)
         hp.plot(setup_axes=True, interactive=True)
         ax.figure.canvas.draw_idle()
         base = Path(path[:-1])
Ejemplo n.º 2
0
def wedge_gap3(path: Path):
    if path == Path(("lorem", "eirmod")):
        return 0, 0.35
    elif path == Path(("ipsum", )):
        return 0, 0.5
    elif path.startswith(Path(("lorem", ))):
        return 0, 0.1
    else:
        return 0, 0
Ejemplo n.º 3
0
def wedge_gap3(path: Path):
    if len(path) == 1:
        return 0.1, 0.1
    elif path == Path((".", ".git", "objects")):
        return 0, 0.1
    elif path == Path((".", ".git")):
        return 0, 0.3
    elif path.startswith(Path((".", ".git"))) and not \
            path.startswith(Path((".", ".git", "objects"))):
        return 0.075, 0.075
    else:
        return 0, 0
 def onClick(event):
     global hp, base
     if event.inaxes == hp.axes and event.button == 1:
         # left click
         for path in hp.wedges:
             cont, ind = hp.wedges[path].contains(event)
             if cont:
                 path = Path(base[:] + path[:])
                 data = {
                     p[len(path) - 1:]: time
                     for p, time in dataAll.items() if p.startswith(path)
                 }
                 ax.clear()
                 hp = HPie(data, ax)
                 hp.plot(setup_axes=True, interactive=True)
                 if options.useTimerNumbers:
                     ax.text(1,
                             0,
                             s,
                             horizontalalignment='left',
                             verticalalignment='bottom',
                             transform=ax.transAxes)
                 ax.figure.canvas.draw_idle()
                 base = Path(path[:-1])
                 break
     elif event.button == 3:
         # right click
         if len(base) > 0:
             path = base
             data = {
                 p[len(path) - 1:]: time
                 for p, time in dataAll.items() if p.startswith(path)
             }
         else:
             path = Path([])
             data = dataAll
         ax.clear()
         hp = HPie(data, ax)
         hp.plot(setup_axes=True, interactive=True)
         if options.useTimerNumbers:
             ax.text(1,
                     0,
                     s,
                     horizontalalignment='left',
                     verticalalignment='bottom',
                     transform=ax.transAxes)
         ax.figure.canvas.draw_idle()
         base = Path(path[:-1])
import csv

# read data

file_size_data_file = realpath(
    join(dirname(__file__), "data", "file_sizes.txt"))

fig, ax = plt.subplots()

data = {}
with open(file_size_data_file) as csvfile:
    reader = csv.reader(csvfile, delimiter="\t")
    for row in reader:
        if not len(row) == 2:
            continue
        data[Path(row[1].split('/'))] = float(row[0])

# do the magic

hp = HPie(data,
          ax,
          cmap=plt.get_cmap("hsv"),
          plot_minimal_angle=0,
          label_minimal_angle=1.5)

# Do not display values
hp.format_value_text = lambda value: None

hp.plot(setup_axes=True)

# set plot attributes
#!/usr/bin/env python3
# -*- coding: utf8 -*-

import os.path
from hpie import Path, paths2dot

numbering = [
    Path(tuple(a)) for a in "1 2 12 13 111 112 113 121 122 211 221 "
    "222 1111 1112 1121".split(" ")
]

with open(
        os.path.join(os.path.dirname(__file__), "figures",
                     "{}.gv".format(os.path.basename(__file__))), "w") as out:
    out.writelines(paths2dot(numbering))
Ejemplo n.º 7
0
            data['/'.join(stack)] = time
            if len(stack) > 1:
                data['/'.join(stack[:-1])] -= time

# create plot
dataAll = stringvalues_to_pv(data)
if not options.non_interactive:

    global hp, base

    ax = plt.gca()
    hp = HPie(dataAll, ax)
    hp.plot(setup_axes=True, interactive=True)

    # set up left and right click actions
    base = Path([])

    def onClick(event):
        global hp, base
        if event.inaxes == hp.axes and event.button == 1:
            # left click
            for path in hp.wedges:
                cont, ind = hp.wedges[path].contains(event)
                if cont:
                    path = Path(base[:] + path[:])
                    data = {
                        p[len(path) - 1:]: time
                        for p, time in dataAll.items() if p.startswith(path)
                    }
                    ax.clear()
                    hp = HPie(data, ax)
Ejemplo n.º 8
0
def wedge_gap2(path: Path):
    if path == Path((".", ".git", "objects")):
        return 0, 0.2
    else:
        return 0, 0
Ejemplo n.º 9
0
 def random_path(self, length):
     path = Path([self.level_population[level][rr(0, self.population_numbers[level])] for level in range(length)])
     return path
Ejemplo n.º 10
0
def wedge_gap2(path: Path):
    if path == Path(("ipsum", )):
        return 0, 0.2
    else:
        return 0, 0