Skip to content
Snippets Groups Projects
Unverified Commit baf3e4bc authored by Benjamin Loison's avatar Benjamin Loison
Browse files

Improve native MLS rendering

parent cf8aea6b
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ with open('data_constant_difficulty.json') as f:
fig, targetsAxis = plt.subplots()
fig.subplots_adjust(right = 0.8)
fig.subplots_adjust(bottom = 0.3)
fig.subplots_adjust(bottom = 0.4)
axes = [targetsAxis, targetsAxis.twinx(), targetsAxis.twinx()]
targets = data['targets']
......@@ -31,26 +31,32 @@ for x, (target, nextTarget) in enumerate(zip(targets, targets[1:])):
if nextTarget > target:
targetIncreaseCurve = plt.axvline(x = x, alpha = 0.5, color = 'red', label = 'target increase')
axesColors = ['blue', 'green', 'brown', 'green', 'brown']
axesColors = ['blue', 'green', 'brown', 'orange', 'brown']
axesLabels = ['targets', 'compressed blockchain size (in blocks)', 'compressed blockchain score', 'constant difficulty compressed blockchain size (in blocks)', 'constant difficulty compressed blockchain score']
axesYValues = [targets, data['compressSize'], data['compressScore'], dataConstantDifficulty['compressSize'], dataConstantDifficulty['compressScore']]
compressedSizeAxis = targetsAxis.twinx()
curves = []
for curvesIndex, (axis, color, label, yValues) in enumerate(zip(axes + axes[-2:], axesColors, axesLabels, axesYValues)):
curves += axis.plot(yValues, '-' if curvesIndex < 3 else '--', label = label, color = color)
for curvesIndex, (axis, color, label, yValues) in enumerate(zip(axes + [compressedSizeAxis] + [axes[-1]], axesColors, axesLabels, axesYValues)):
dashes = (None, None) if curvesIndex != 4 else [1, 25]
alpha = 1 if curvesIndex != 3 else 0.5
curves += axis.plot(yValues, label = label, color = color, dashes = dashes, alpha = alpha)
targetsAxis.set_yscale('log')
axes[2].spines.right.set_position(('axes', 1.1))
axes[2].set_yscale('log')
compressedSizeAxis.spines.right.set_position(('axes', 1.2))
legendNewLine = targetsAxis.plot([], [], color='none', label=' ')
sameAxes = targetsAxis.plot([], [], color='none', label='Respectively same axes as two previous curves:')
curves.insert(-2, sameAxes[0])
curves.insert(-2, legendNewLine[0])
curves += legendNewLine + targetRecomputationCurve + [firstTargetDecreaseCurve] + [targetIncreaseCurve]
labels = [curve.get_label() for curve in curves]
plt.legend(curves, labels, loc='upper center', framealpha=1, bbox_to_anchor=(0.5, -0.1))
plt.legend(curves, labels, loc='upper center', framealpha=1, bbox_to_anchor=(0.5, -0.125))
targetsAxis.set_xlabel('Block height')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment