Commit 28d00786 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1d1e8ba6
...@@ -107,25 +107,37 @@ def xseriesof(B): ...@@ -107,25 +107,37 @@ def xseriesof(B):
return S return S
# yticklabel_forvalue returns text for ytick label dedicated to showing particular value. # add_yvalueticks adds small yticks for values in yv.
# def add_yvalueticks(ax, yv):
# it is a bit smaller in size and cares not to overlap with neighbours. ys0 = set(ax.get_yticks())
def yticklabel_forvalue(yv, yvprev, yvnext): ys = ys0.copy()
# smaller in size (not to overload / overlap) ys.update(yv)
# (NOTE our custom ticks are not at edges: i-1 and i+1 are always in range) yv = list(ys)
if yv - yvprev > yvnext - yv: yv.sort()
ylabv = []
for i, y in enumerate(yv):
if y in ys0:
l = '%d' % y
else:
# choose ytick label for this to particular value.
# it is a bit smaller in size and cares not to overlap with neighbours.
yprev = (yv[i-1] if i > 0 else 0)
ynext = (yv[i+1] if i + 1 < len(yv) else float('inf'))
if y - yprev > ynext - y:
d = '_' # shift a bit down d = '_' # shift a bit down
#d = '_^' # shift a bit down #d = '_^' # shift a bit down
else: else:
d = '^' # shift a bit up d = '^' # shift a bit up
#d = '^_' # shift a bit up #d = '^_' # shift a bit up
l = r'${}%s{%d}$' % (d, yv) l = r'${}%s{%d}$' % (d, y)
#l = r'${}%s{{}%s{%d}}$' % (d[0], d[1], yv) #l = r'${}%s{{}%s{%d}}$' % (d[0], d[1], y)
return l
ylabv.append(l)
ax.set_yticks(yv)
ax.set_yticklabels(ylabv)
# stylefor is {} name -> Line2D style kw, so that we can always use e.g. the # stylefor is {} name -> Line2D style kw, so that we can always use e.g. the
...@@ -203,25 +215,7 @@ def plotseries(ax, labkey, S): ...@@ -203,25 +215,7 @@ def plotseries(ax, labkey, S):
ax.set_xticks(xtickv) ax.set_xticks(xtickv)
# mark first values with dedicated y ticks. # mark first values with dedicated y ticks.
yticks = set(ax.get_yticks()) add_yvalueticks(ax, yticks0)
yticks.update(yticks0)
ytickv = list(yticks)
ytickv.sort()
yticklabv = []
for i, _ in enumerate(ytickv):
if _ not in yticks0:
l = '%d' % _
else:
yprev = (ytickv[i-1] if i > 0 else 0)
ynext = (ytickv[i+1] if i + 1 < len(ytickv) else float('inf'))
l = yticklabel_forvalue(_, yprev, ynext)
yticklabv.append(l)
ax.set_yticks(ytickv)
ax.set_yticklabels(yticklabv)
# always start y from 0 (it goes to -500 for latencies if auto) # always start y from 0 (it goes to -500 for latencies if auto)
ax.set_ylim(bottom=0) ax.set_ylim(bottom=0)
...@@ -230,29 +224,20 @@ def plotseries(ax, labkey, S): ...@@ -230,29 +224,20 @@ def plotseries(ax, labkey, S):
# show on the right ticks for last y values # show on the right ticks for last y values
ax2 = ax.twinx() ax2 = ax.twinx()
ax2.set_ylim(ax.get_ylim()) # same y scale as on ax ax2.set_ylim(ax.get_ylim()) # same y scale as on ax
ytick_v = list(yticks_) add_yvalueticks(ax2, yticks_)
ytick_v.sort()
ytick_labv = []
for i, _ in enumerate(ytick_v):
yprev = (ytick_v[i-1] if i > 0 else 0)
ynext = (ytick_v[i+1] if i + 1 < len(ytick_v) else float('inf'))
l = yticklabel_forvalue(_, yprev, ynext)
ytick_labv.append(l)
ax2.set_yticks(ytick_v)
ax2.set_yticklabels(ytick_labv)
# plotlat1 makes plot of benchmark latencies for serial (1 client) case. # plotlat1 makes plot of benchmark latencies for serial (1 client) case.
def plotlat1(ax, S): def plotlat1(ax, S):
# XXX use the same color/style for name as in different plot yticks0 = set()
for name in S: for name in S:
b = S[name].series[0] b = S[name].series[0]
if b[0] != 1: # n if b[0] != 1: # n
continue continue
s = b[1] # stats s = b[1] # stats
yticks0.add(s.avg)
# 1 hand-made error bar (cannot control line styles of cap lines with errorbar) # 1 hand-made error bar (cannot control line styles of cap lines with errorbar)
w = 0.15 w = 0.15
...@@ -263,6 +248,9 @@ def plotlat1(ax, S): ...@@ -263,6 +248,9 @@ def plotlat1(ax, S):
#ax.legend() # XXX temp #ax.legend() # XXX temp
# mark first values with dedicated y ticks
add_yvalueticks(ax, yticks0)
......
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