Skip to content

Commit 544d23a

Browse files
committed
edit peri_event_time_histogram to not allow error bars turns to negative value and not plot raster when no spikes
1 parent f76a936 commit 544d23a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

brainbox/plot.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,11 @@ def peri_event_time_histogram(
578578
else:
579579
bars = np.zeros_like(mean)
580580
if error_bars != 'none':
581-
ax.fill_between(peths.tscale, mean - bars, mean + bars, **errbar_kwargs)
581+
negative_bar=mean-bars
582+
if np.any(negative_bar<0):
583+
ax.fill_between(peths.tscale, 0, mean + bars, **errbar_kwargs)
584+
else:
585+
ax.fill_between(peths.tscale, negative_bar, mean + bars, **errbar_kwargs)
582586

583587
# Plot the event marker line. Extends to 5% higher than max value of means plus any error bar.
584588
plot_edge = (mean.max() + bars[mean.argmax()]) * 1.05
@@ -588,6 +592,13 @@ def peri_event_time_histogram(
588592
# blank space below the zero where the raster will go.
589593
ax.set_xlim([-t_before, t_after])
590594
ax.set_ylim([-plot_edge if include_raster else 0., plot_edge])
595+
if int(plot_edge)==0:
596+
include_raster=False
597+
598+
if mean.min()!=0:
599+
ax.set_yticks(0,mean.min(),mean.max())
600+
else:
601+
ax.set_yticks([0,mean.max()])
591602
# Put y ticks only at min, max, and zero
592603
if mean.min() != 0:
593604
ax.set_yticks([0, mean.min(), mean.max()])

0 commit comments

Comments
 (0)