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])
 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])
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
ax.set_title("Disk Usage Chart")

# save/show plot

fig.set_size_inches(10, 10)
fig.savefig(os.path.join(os.path.dirname(__file__), "figures",
    29.,
    '121',
    43.,
    '13',
    69.,
    '211',
    43.,
])

axs[0].set_title('Default Order')
axs[1].set_title('Alphabetic Order')
axs[2].set_title('Order by Value Increasing')
axs[3].set_title('Keep Order')

hps = [
    HPie(data, axs[0]),
    HPie(data, axs[1], order="key"),
    HPie(data, axs[2], order="value reverse"),
    HPie(data_ordered, axs[3], order="keep")
]

for i, hp in enumerate(hps):
    hp.plot(setup_axes=True)

fig.tight_layout(pad=0.5)

# save/show plot

fig.savefig(os.path.join(os.path.dirname(__file__), "figures",
                         "{}.png".format(os.path.basename(__file__))),
            dpi=100,
data = stringvalues_to_pv({
    'ipsum/?/?':                 40.45,
    'ipsum/eirmod/?':            29.34,
    'ipsum/eirmod/dolor':        94.4,
    'lorem/?/?':                 36.12,
    'lorem/sadipscing/dolor':    44.32,
    'lorem/sadipscing/lorem':    37.15,
    'lorem/sadipscing/nonumy':   23.98,
    'lorem/eirmod/?':            11.12,
    'lorem/eirmod/lorem':        45.65,
    'lorem/sadipscing/?':        79.67,
})

# do the magic

hp = HPie(data, ax)

# set plot attributes

hp.plot(setup_axes=True)
ax.set_title('Minimal Example (Rings)')

# save/show plot

fig.savefig(os.path.join(os.path.dirname(__file__), "figures",
                         "{}.png".format(os.path.basename(__file__))),
            dpi=100,
            bbox_inches='tight')

if __name__ == "__main__":
    plt.show()
            time = float(match[2])
            depth = separator.count('|')
            stack = stack[:depth - 1] + [label]
            prevDepth = depth
            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
Exemple #7
0
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])

axs[0].set_title('Explosion scaled with (1/depth)^2')
axs[1].set_title('Uniform Explosion')
axs[2].set_title('Explode one slice')
axs[3].set_title('Explode wedges independently')

hps = [
    HPie(data,
         ax,
         cmap=plt.get_cmap("hsv"),
         plot_minimal_angle=0,
         label_minimal_angle=1.5) for ax in axs
]


def wedge_gap0(path: Path):
    return 0, 1 / (1 + len(path))**2


# noinspection PyUnusedLocal
def wedge_gap1(path: Path):
    return 0, 0.1


def wedge_gap2(path: Path):
Exemple #8
0
        loremipsum = "Lorem ipsum dolor ame consetetur sadipscing elit " \
                          "sed diam nonumy eirmod tempor invidunt " \
                          "labore dolore".split(" ")
    else:
        loremipsum = list(map(str, range(10)))
    p_numbers = [int(i) for i in sys.argv[2].split(',')]
    n_paths = int(sys.argv[3])
    rhd = RandomHdata(loremipsum, p_numbers)
    paths = rhd.paths(n_paths)
    pathvalues = {path: rr(1, 1000)/10 for path in paths}

    # pretty print
    # print(data)
    print("{")
    for path, value in pathvalues.items():
        print("\t{}: {},".format(repr(path), value))
    print("}")

    fig, ax = plt.subplots()

    hp = HPie(pathvalues, ax)

    hp.plot(setup_axes=True)
    ax.set_title('Example HPie')

    # save/show plot

    fig.savefig(os.path.join(os.path.dirname(__file__), "figures",
                             "{}.png".format(os.path.basename(__file__))),
                dpi=100,
                bbox_inches='tight')
Exemple #9
0
data = stringvalues_to_pv({
    'ipsum': 40.45,
    'ipsum/eirmod': 29.34,
    'ipsum/eirmod/dolor': 94.4,
    'lorem': 36.12,
    'lorem/sadipscing/dolor': 44.32,
    'lorem/sadipscing/lorem': 37.15,
    'lorem/sadipscing/nonumy': 23.98,
    'lorem/eirmod': 11.12,
    'lorem/eirmod/lorem': 45.65,
    'lorem/sadipscing': 79.67,
})

# do the magic

hp = HPie(data, ax, base_line_width=1)

# set plot attributes


def nothing(*args, **kwargs):
    return ""


hp.format_text = nothing

hp.plot(setup_axes=True)
# ax.set_title('Minimal Example')

# save/show plot
Exemple #10
0
    'lorem':                      36.12,
    'lorem/sadipscing/dolor':     44.32,
    'lorem/sadipscing/lorem':     37.15,
    'lorem/sadipscing/nonumy':    23.98,
    'lorem/eirmod':               11.12,
    'lorem/eirmod/lorem':         45.65,
    'lorem/sadipscing':           79.67,
})


axs[0].set_title('Standard HPie')
axs[1].set_title('Completely exploded')
axs[2].set_title('Explode one slice')
axs[3].set_title('Explode multiple slices')

hps = [HPie(data, ax) for ax in axs]


# noinspection PyUnusedLocal
def wedge_gap1(path: Path):
    return 0, 0.1


def wedge_gap2(path: Path):
    if path == Path(("ipsum", )):
        return 0, 0.2
    else:
        return 0, 0


def wedge_gap3(path: Path):