Commit 06f1d772 authored by Andreas Schmidt's avatar Andreas Schmidt

Fix graph.

parent 87ed00ce
......@@ -120,27 +120,27 @@ def _plot_controlflow_graph(df, hdb):
# Taken from: http://composition.al/blog/2015/11/29/a-better-way-to-add-labels-to-bar-charts-with-matplotlib/
def autolabel(rects, ax, labels):
# Get y-axis height to calculate label position from.
(y_bottom, y_top) = ax.get_ylim()
y_height = y_top - y_bottom
(x_left, x_right) = ax.get_xlim()
x_width = x_right - x_left
for i, rect in enumerate(rects):
height = rect.get_height()
width = rect.get_width()
color = "black"
align = "left"
# Fraction of axis height taken up by this rectangle
p_height = (height / y_height)
p_width = (width / x_width)
# If we can fit the label above the column, do that;
# otherwise, put it inside the column.
if p_height > 0.50: # arbitrary; 95% looked good to me.
label_position = 0.01
if p_width > 0.50: # arbitrary; 95% looked good to me.
label_position = width - (x_width) + 0.7
color = "white"
align = "right"
else:
label_position = height + (y_height * 0.01)
label_position = width + (x_width * 0.01)
ax.text(rect.get_x() + rect.get_width()/2., label_position,
labels[i],
ha='center', va='bottom', rotation=90, color=color)
ax.text(label_position, rect.get_y(), labels[i], ha=align, va='bottom', rotation=0, color=color)
def _plot_critical_regions(df,hdb):
......@@ -156,7 +156,7 @@ def _plot_critical_regions(df,hdb):
correlations = list(map(lambda x: x['Correlation'], relevant))
ticks = list(map(lambda x: "%s-%s" % (x['Start'][:-2], x['End'][:-2]), relevant))
fig, ax = plt.subplots()
rects = ax.bar(x, correlations, align="center", tick_label="")
rects = ax.barh(x, correlations, align="center", tick_label="")
autolabel(rects, ax, ticks)
# TODO: find a more elegant solution for the label text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment