Skip to content

Commit

Permalink
edit peri_event_time_histogram to not allow error bars turns to negat…
Browse files Browse the repository at this point in the history
…ive value and not plot raster when no spikes
  • Loading branch information
chiyu1203 committed May 17, 2024
1 parent f76a936 commit 544d23a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion brainbox/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,11 @@ def peri_event_time_histogram(
else:
bars = np.zeros_like(mean)
if error_bars != 'none':
ax.fill_between(peths.tscale, mean - bars, mean + bars, **errbar_kwargs)
negative_bar=mean-bars
if np.any(negative_bar<0):
ax.fill_between(peths.tscale, 0, mean + bars, **errbar_kwargs)
else:
ax.fill_between(peths.tscale, negative_bar, mean + bars, **errbar_kwargs)

# Plot the event marker line. Extends to 5% higher than max value of means plus any error bar.
plot_edge = (mean.max() + bars[mean.argmax()]) * 1.05
Expand All @@ -588,6 +592,13 @@ def peri_event_time_histogram(
# blank space below the zero where the raster will go.
ax.set_xlim([-t_before, t_after])
ax.set_ylim([-plot_edge if include_raster else 0., plot_edge])
if int(plot_edge)==0:
include_raster=False

if mean.min()!=0:
ax.set_yticks(0,mean.min(),mean.max())
else:
ax.set_yticks([0,mean.max()])
# Put y ticks only at min, max, and zero
if mean.min() != 0:
ax.set_yticks([0, mean.min(), mean.max()])
Expand Down

0 comments on commit 544d23a

Please sign in to comment.