コード例 #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])
コード例 #2
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])
コード例 #3
0
        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",
                         "{}.png".format(os.path.basename(__file__))),
            dpi=100,
            bbox_inches='tight')

if __name__ == "__main__":
    plt.show()
コード例 #4
0
            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
                        for p, time in dataAll.items() if p.startswith(path)