Commit 3cc35d81 authored by Stefan Reif's avatar Stefan Reif
Browse files

...

parent ccba7c21
...@@ -5,6 +5,13 @@ from scipy import stats ...@@ -5,6 +5,13 @@ from scipy import stats
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import xlap.analyse.latency as latency import xlap.analyse.latency as latency
plt.rcParams['ps.useafm'] = True
plt.rcParams['pdf.use14corefonts'] = True
plt.rcParams['text.usetex'] = False
plt.rcParams['font.family'] = 'sans-serif'
#plt.rcParams['font.sans-serif'] = 'Latin Modern Sans'
#plt.rcParams['font.monospace'] = 'FreeMono'
# Taken from: http://composition.al/blog/2015/11/29/a-better-way-to-add-labels-to-bar-charts-with-matplotlib/ # 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): def autolabel(rects, ax, labels):
# Get y-axis height to calculate label position from. # Get y-axis height to calculate label position from.
...@@ -26,7 +33,7 @@ def autolabel(rects, ax, labels): ...@@ -26,7 +33,7 @@ def autolabel(rects, ax, labels):
color = "white" color = "white"
align = "right" align = "right"
else: else:
label_position = width + (x_width * 0.01) label_position = width + (x_width * 0.00)
mono = {'family': 'monospace'} mono = {'family': 'monospace'}
ax.text(label_position, rect.get_y(), labels[i], ha=align, va='bottom', rotation=0, color=color, fontdict=mono) ax.text(label_position, rect.get_y(), labels[i], ha=align, va='bottom', rotation=0, color=color, fontdict=mono)
...@@ -41,7 +48,8 @@ def _plot_regions(dataset): ...@@ -41,7 +48,8 @@ def _plot_regions(dataset):
correlations = list(map(lambda x: x['Slowdown'], relevant)) correlations = list(map(lambda x: x['Slowdown'], relevant))
ticks = list(map(lambda x: "<%s,%s>" % (x['Start'][:-2], x['End'][:-2]), relevant)) ticks = list(map(lambda x: "<%s,%s>" % (x['Start'][:-2], x['End'][:-2]), relevant))
fig, ax = plt.subplots() fig, ax = plt.subplots()
rects = ax.barh(x, correlations, align="center", tick_label="", color='#3babaf') #rects = ax.barh(x, correlations, align="center", tick_label="", color='#3babaf')
rects = ax.barh(x, correlations, align="center", tick_label="")
autolabel(rects, ax, ticks) autolabel(rects, ax, ticks)
plt.xlabel('Normalized slowdown') plt.xlabel('Normalized slowdown')
......
...@@ -5,9 +5,15 @@ import numpy as np ...@@ -5,9 +5,15 @@ import numpy as np
import sys import sys
import graphviz import graphviz
class LatencyAnalysis(): class LatencyAnalysis():
def __init__(self, cfg=None, hdb=None): def __init__(self, cfg=None, hdb=None):
plt.rcParams['ps.useafm'] = True
plt.rcParams['pdf.use14corefonts'] = True
plt.rcParams['text.usetex'] = False
plt.rcParams['font.family'] = 'sans-serif'
#plt.rcParams['font.sans-serif'] = 'Latin Modern Sans'
#plt.rcParams['font.monospace'] = 'FreeMono'
self.cfg = cfg self.cfg = cfg
correlations = [] correlations = []
...@@ -152,13 +158,15 @@ def autolabel(rects, ax, labels): ...@@ -152,13 +158,15 @@ def autolabel(rects, ax, labels):
# If we can fit the label above the column, do that; # If we can fit the label above the column, do that;
# otherwise, put it inside the column. # otherwise, put it inside the column.
if p_width > 0.50: # arbitrary; 95% looked good to me. if p_width > 0.50: # arbitrary; 95% looked good to me.
label_position = width - (x_width) + 0.7 #label_position = width - (x_width) + 0.7
label_position = width - (x_width * 0.01)
color = "white" color = "white"
align = "right" align = "right"
else: else:
label_position = width + (x_width * 0.01) label_position = width + (x_width * 0.002)
ax.text(label_position, rect.get_y(), labels[i], ha=align, va='bottom', rotation=0, color=color) mono = {'family': 'monospace'}
ax.text(label_position, rect.get_y(), labels[i], ha=align, va='bottom', rotation=0, color=color, fontdict=mono)
def _plot_critical_regions(hdb): def _plot_critical_regions(hdb):
...@@ -169,11 +177,12 @@ def _plot_critical_regions(hdb): ...@@ -169,11 +177,12 @@ def _plot_critical_regions(hdb):
x = np.arange(len(relevant)) x = np.arange(len(relevant))
correlations = list(map(lambda x: x['Correlation'], relevant)) correlations = list(map(lambda x: x['Correlation'], relevant))
ticks = list(map(lambda x: "%s-%s" % (x['Start'][:-2], x['End'][:-2]), relevant)) ticks = list(map(lambda x: "<%s,%s>" % (x['Start'][:-2], x['End'][:-2]), relevant))
fig, ax = plt.subplots() fig, ax = plt.subplots()
rects = ax.barh(x, correlations, align="center", tick_label="") rects = ax.barh(x, correlations, align="center", tick_label="")
autolabel(rects, ax, ticks) autolabel(rects, ax, ticks)
plt.xlabel('Latency criticality')
plt.tight_layout() plt.tight_layout()
plt.savefig("latency-criticality.pdf") plt.savefig("latency-criticality.pdf")
plt.close() plt.close()
......
Supports Markdown
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