Skip to content

Commit

Permalink
Minor cleanup of visualizations.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Niru Maheswaranathan committed Oct 12, 2016
2 parents 5608de8 + a6d839a commit c0e34f7
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions pyret/visualizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def rasterandpsth(spikes, trial_length=None, binsize=0.01, **kwargs):
fig : matplotlib Figure handle
Matplotlib figure handle
"""
fig, ax = kwargs['fig'], kwargs['ax']
ax = kwargs['ax']

# Input-checking
if not trial_length:
Expand All @@ -164,23 +164,22 @@ def rasterandpsth(spikes, trial_length=None, binsize=0.01, **kwargs):
fr = np.mean(bspk, axis=0) / binsize

# Plot the PSTH
psthax = fig.add_subplot(111)
psthax.plot(tbins[0, :-1], fr, color='r', marker=None, linestyle='-', linewidth=2)
psthax.set_title('psth and raster', fontdict={'fontsize':24})
psthax.set_xlabel('time (s)', fontdict={'fontsize':20})
psthax.set_ylabel('firing rate (Hz)', color='r', fontdict={'fontsize':20})
for tick in psthax.get_yticklabels():
ax.plot(tbins[0, :-1], fr, color='r', marker=None, linestyle='-', linewidth=2)
ax.set_title('psth and raster', fontdict={'fontsize': 24})
ax.set_xlabel('time (s)', fontdict={'fontsize': 20})
ax.set_ylabel('firing rate (Hz)', color='r', fontdict={'fontsize': 20})
for tick in ax.get_yticklabels():
tick.set_color('r')

# Plot the raster
rastax = psthax.twinx()
rastax = ax.twinx()
plt.hold(True)
for trial in range(ntrials):
idx = np.bitwise_and(spikes > tbins[trial, 0], spikes <= tbins[trial, -1])
rastax.plot(spikes[idx] - tbins[trial, 0], trial * np.ones(spikes[idx].shape),
color='k', marker='.', linestyle='none')
rastax.set_ylabel('trial #', color='k', fontdict={'fontsize':20})
for tick in psthax.get_yticklabels():
rastax.set_ylabel('trial #', color='k', fontdict={'fontsize': 20})
for tick in ax.get_yticklabels():
tick.set_color('k')


Expand Down

0 comments on commit c0e34f7

Please sign in to comment.