From 5dd2c92f1631c2accc2041ce5bfcdec29828dc9c Mon Sep 17 00:00:00 2001 From: Saurabh Mogre Date: Thu, 22 Jun 2023 15:33:36 -0700 Subject: [PATCH] Only plot histogram if more than 2 bins --- cellpack/autopack/Analysis.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cellpack/autopack/Analysis.py b/cellpack/autopack/Analysis.py index 33801ae85..fdccebb34 100644 --- a/cellpack/autopack/Analysis.py +++ b/cellpack/autopack/Analysis.py @@ -1709,6 +1709,8 @@ def histo(self, distances, filename, title_str="", x_label="", y_label=""): plt.clf() # calculate histogram nbins = int(numpy.sqrt(len(distances))) + if nbins < 2: + return y, bin_edges = numpy.histogram(distances, bins=nbins) bincenters = 0.5 * (bin_edges[1:] + bin_edges[:-1])