def update_payments_graph(screen, response): """function docstring""" payments = [ float(str(rate[1]).encode('UTF8')) for rate in response['charts']['payments'] ] timestamps = [ float(str(rate[0]).encode('UTF8')) for rate in response['charts']['payments'] ] payments_start = datetime.datetime.fromtimestamp(timestamps[0]) payments_start = payments_start.strftime('%b %d @ %-I:%M %p') payments_stop = datetime.datetime.fromtimestamp( timestamps[len(timestamps) - 1]) payments_stop = payments_stop.strftime('%b %d @ %-I:%M %p') title = payments_start + ' - ' + payments_stop screen.addstr(34, 3, 'Payments (ETN)') screen.addstr(34, screen.getmaxyx()[1] - len(title) - 2, title) graph = plot(timestamps, payments, output=str) lines = graph.split('\n') lines[1] = modify_minmax(lines[1]) lines[len(lines) - 2] = modify_minmax(lines[len(lines) - 2]) for i in range(1, len(lines) - 1): screen.addstr(36 + i, (screen.getmaxyx()[1] - len(lines[0])) / 2, lines[i])
def update_hashrate_graph(screen, response): """function docstring""" hashrates = [rate[1] for rate in response['charts']['hashrate']] timestamps = [rate[0] for rate in response['charts']['hashrate']] hashrates_start = datetime.datetime.fromtimestamp( timestamps[0]).strftime('%b %d @ %-I:%M %p') last_timestamp = timestamps[len(timestamps) - 1] hashrates_stop = datetime.datetime.fromtimestamp(last_timestamp).strftime( '%b %d @ %-I:%M %p') title = hashrates_start + ' - ' + hashrates_stop screen.addstr(11, 3, 'Hashrate (H/sec)') screen.addstr(11, screen.getmaxyx()[1] - len(title) - 2, title) graph = plot(timestamps, hashrates, output=str) lines = graph.split('\n') for i in range(1, len(lines) - 1): screen.addstr(13 + i, (screen.getmaxyx()[1] - len(lines[0])) / 2, lines[i])
"""Make plot of a curve in pure text format (ASCII).""" # this is the same example as in the scitools.aplotter doc string from scitools.aplotter import plot from numpy import linspace, exp, cos, pi x = linspace(-2, 2, 81) y = exp(-0.5 * x**2) * cos(pi * x) plot(x, y) plot(x, y, draw_axes=False) # plot symbols (the dot argument) at data points: plot(x, y, plot_slope=False) # drop axis labels: plot(x, y, plot_labels=False) plot(x, y, dot='o', plot_slope=False) # store plot in a string: p = plot(x, y, output=str) print p
"""Make plot of a curve in pure text format (ASCII).""" # This is the same example as in the scitools.aplotter doc string import numpy as np x = np.linspace(-2, 2, 81) y = np.exp(-0.5*x**2)*np.cos(np.pi*x) from scitools.aplotter import plot plot(x, y) plot(x, y, draw_axes=False) # Plot symbols (the dot argument) at data points plot(x, y, plot_slope=False) # Drop axis labels plot(x, y, plot_labels=False) plot(x, y, dot='o', plot_slope=False) # Store plot in a string p = plot(x, y, output=str) print p