import neo
import quantities as pq
import matplotlib.pyplot as plt
from elephant.spike_train_generation import homogeneous_poisson_process
from elephant import statistics
from viziphant.statistics import plot_time_histogram
from viziphant.events import add_event
np.random.seed(11)

fig, axes = plt.subplots(2, 1, sharex=True, sharey=True)
event = neo.Event([2]*pq.s, labels=['Trigger ON'])
for axis in axes:
    spiketrains = [homogeneous_poisson_process(rate=10 * pq.Hz,
                   t_stop=10 * pq.s) for _ in range(10)]
    histogram = statistics.time_histogram(spiketrains,
                                          bin_size=0.1 * pq.s,
                                          output='rate')
    plot_time_histogram(histogram, axes=axis, units='s')
add_event(axes, event=event)
plt.show()