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

Display dates temporarily instead of block height

parent 5abfedd7
Branches
No related tags found
No related merge requests found
import json
import math
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import datetime
SHOW_TARGET_RECOMPUTATION = False
......@@ -22,29 +24,38 @@ axes = [targetsAxis, compressedSizeAxis, compressedScoreAxis, targetsAxis.twinx(
targets = data['targets']
timestamps = [datetime.datetime.fromtimestamp(timestamp) for timestamp in data['timestamps']]
for x, (target, nextTarget) in enumerate(zip(targets, targets[1:])):
if nextTarget < target:
firstTargetDecreaseCurve = plt.axvline(x = x, color = 'purple', label = 'first target decrease')
firstTargetDecreaseCurve = plt.axvline(x = timestamps[x], color = 'purple', label = 'first target decrease')
break
targetRecomputationCurve = []
if SHOW_TARGET_RECOMPUTATION:
for x in range(0, len(targets), 2016):
targetRecomputationCurve = [plt.axvline(x = x, alpha = 0.1, label = 'target recomputation')]
targetRecomputationCurve = [plt.axvline(x = timestamps[x], alpha = 0.1, label = 'target recomputation')]
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')
targetIncreaseCurve = plt.axvline(x = timestamps[x], alpha = 0.5, color = 'red', label = 'target increase')
axesColors = ['blue', 'green', 'brown', 'orange', 'brown', 'red', 'purple']
axesLabels = ['targets', 'compressed blockchain size (in blocks)', 'compressed blockchain score', 'constant difficulty compressed blockchain size (in blocks)', 'constant difficulty compressed blockchain score', 'compressed blockchain size keeping all blocks since last m higher block (in blocks)', 'compressed blockchain score keeping all blocks since last m higher block']
axesYValues = [targets, data['compressSize'], data['compressScore'], dataConstantDifficulty['compressSize'], dataConstantDifficulty['compressScore'], dataKeepingAllBlocksSinceLastMHigherBlock['compressSize'], dataKeepingAllBlocksSinceLastMHigherBlock['compressScore']]
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%m/%Y'))
curves = []
for curvesIndex, (axis, color, label, yValues) in enumerate(zip(axes, 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)
# TODO: remove below
# Due to not having exported `timestamps` for every execution:
comparableLength = min(len(timestamps), len(yValues))
curves += axis.plot(timestamps[:comparableLength], yValues[:comparableLength], label = label, color = color, dashes = dashes, alpha = alpha)
plt.gcf().autofmt_xdate()
targetsAxis.set_yscale('log', base=2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment