In [1]:
import numpy as np
from lets_plot import *
LetsPlot.setup_html()

class ggmatrix():
    def __init__(self, plot_width, plot_height):
        self.bunch = GGBunch()
        self.plot_width = plot_width
        self.plot_height = plot_height
        
    def add(self, col, row, spec):
        self.bunch.add_plot(spec, col * self.plot_width, row * self.plot_height, self.plot_width, self.plot_height)
        
    def show(self):
        self.bunch.show()
In [2]:
def time_plot(title, time, y=False):
    np.random.seed(0)
    value = np.random.normal(loc=-5, scale=6, size=len(time))
    d = {'time': time, 'value': value}
    if y:
        return ggplot(d) + geom_line(aes('value', 'time')) + scale_y_time() + ggtitle(title)
    else:
        return ggplot(d) + geom_line(aes('time', 'value')) + scale_x_time() + ggtitle(title)

def serie(start, end, duration, step = None):
    if step is None:
        step = 1 * duration
        
    return [v for v in range(start * duration, end * duration, step)]

MS = 1
SECOND = 1000 * MS
MINUTE = 60 * SECOND
HOUR = 60 * MINUTE
In [3]:
matrix = ggmatrix(480, 300)
matrix.add(0, 0, time_plot("5 seconds", serie(0, 5000, MS, step = 5*MS)))
matrix.add(1, 0, time_plot("24 hours", serie(0, 24, HOUR, step = 30*MINUTE)))
matrix.add(0, 1, time_plot("5 days", serie(0, 120, HOUR)))
matrix.add(1, 1, time_plot("30 days", serie(0, 720, HOUR)))
matrix.add(0, 2, time_plot("-30..30 minutes", serie(-30, 30, MINUTE)))
matrix.add(1, 2, time_plot("-30..30 minutes + scale_y_time()", serie(-30, 30, MINUTE), y=True))
matrix.show()