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

Get rid of unneeded `DateFormatter` stuff

parent 4e0f1dfc
No related branches found
No related tags found
No related merge requests found
......@@ -44,13 +44,13 @@ 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']]
class DateFormatter(ticker.Formatter):
class CustomDateFormatter(ticker.Formatter):
"""
Format a tick (in days since the epoch) with a
`~datetime.datetime.strftime` format string.
"""
def __init__(self, fmt, tz=None, *, usetex=None):
def __init__(self, fmt, tz=None):
"""
Parameters
----------
......@@ -58,23 +58,15 @@ class DateFormatter(ticker.Formatter):
`~datetime.datetime.strftime` format string
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
usetex : bool, default: :rc:`text.usetex`
To enable/disable the use of TeX's math mode for rendering the
results of the formatter.
"""
self.tz = _get_tzinfo(tz)
self.fmt = fmt
self._usetex = (usetex if usetex is not None else
mpl.rcParams['text.usetex'])
def __call__(self, x, pos=0):
result = num2date(x, self.tz).strftime(self.fmt)
return _wrap_in_tex(result) if self._usetex else result
return result
def set_tzinfo(self, tz):
self.tz = _get_tzinfo(tz)
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%m/%Y'))
plt.gca().xaxis.set_major_formatter(CustomDateFormatter('%m/%Y'))
curves = []
for curvesIndex, (axis, color, label, yValues) in enumerate(zip(axes, axesColors, axesLabels, axesYValues)):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment