10 examples of 'plot histogram python' in Python

Every line of 'plot histogram python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
48def plot_histogram(values, num_bins=100):
49 """
50 Generates a plot of the histograms of grasps by probability of force closure
51 """
52 bin_edges = np.linspace(np.min(values), np.max(values), num_bins+1)
53 plt.figure()
54 n, bins, patches = plt.hist(values, bin_edges)
330def plot_histogram(x, fname, bins=np.arange(0, 7) + 0.5, xlabel="proposal", ylabel="Counts"):
331 plt.figure()
332 plt.hist(x, bins, histtype='bar', facecolor='green', rwidth=0.8)
333 plt.xlabel(xlabel)
334 plt.ylabel(ylabel)
335 plt.savefig(fname + ".png")
336 plt.close()
70def plot_histogram(self, naxes, hist_edges, hist):
71 hist_width = 256/len(hist)
72 if naxes not in self.histograms:
73 self.histograms[naxes] = self.axes[naxes].bar(
74 hist_edges[:-1], hist, width=hist_width, facecolor="#dbdbdb",
75 align="edge")
76 else:
77 for i, rect in enumerate(self.histograms[naxes]):
78 rect.set_height(hist[i])
79 rect.set_x(hist_edges[i])
80 if naxes == len(self.histograms)-1:
81 self.canvas.draw()
18def plot_2d_hist(x1, x2, bins=10):
19 plt.hist2d(x1, x2, bins=10, norm=LogNorm())
20 plt.colorbar()
21 plt.show()
88def plot_hist(axes, data, xlabel=None, log=False, avg=True, median=True, bins=None, **kwargs):
89 time_max = max(data)
90 time_min = min(data)
91 time_avg = np.average(data)
92 time_median = np.median(data)
93 if bins is None:
94 bins = time_max - time_min + 1
95 hist = axes.hist(data, bins=bins, log=log, **kwargs)
96 if avg:
97 axes.axvline(x=time_avg, alpha=0.7, linestyle="dotted", color="blue", label="avg = {}".format(time_avg))
98 if median:
99 axes.axvline(x=time_median, alpha=0.7, linestyle="dotted", color="green", label="median = {}".format(time_median))
100 axes.set_ylabel("count" + ("\n(log)" if log else ""))
101 axes.set_xlabel("time" if xlabel is None else xlabel)
102 axes.xaxis.set_major_locator(ticker.MaxNLocator())
103 if avg or median:
104 axes.legend(loc="best")
105 return hist
23@timing_func
24def plotHistogram3D(image, num_bins, color_space, ax):
25 font_size = 15
26 plt.title("%s: %s bins" % (color_space, num_bins), fontsize=font_size)
27
28 hist3D = Hist3D(image, num_bins=num_bins, color_space=color_space)
29 hist3D.plot(ax)
23def show_hist_with_matplotlib_gray(hist, title, pos, color):
24 """Shows the histogram using matplotlib capabilities"""
25
26 ax = plt.subplot(2, 3, pos)
27 # plt.title(title)
28 plt.xlabel("bins")
29 plt.ylabel("number of pixels")
30 plt.xlim([0, 256])
31 plt.plot(hist, color=color)
134def compare_hist(hist, bins, like, x, figname, discrete=False):
135 """Plot and save a figure comparing the histogram with the
136 probability.
137
138 :Parameters:
139 - `samples`: random variables.
140 - `like`: probability values.
141 - `bins`: histogram bins.
142 - `x`: values at which like is computed.
143 - `figname`: Name of figure to save.
144 """
145 ax = P.subplot(111)
146 width = 0.9*(bins[1]-bins[0])
147 ax.bar(bins, hist, width)
148 P.setp(ax.patches, alpha=.5)
149 if discrete:
150 ax.plot(x, like, 'k', linestyle='steps')
151 else:
152 ax.plot(x, like, 'k')
153 P.savefig('figs/' + figname)
154 P.close()
147def histogram(image):
148 hist = cv2.calcHist([image], [0], None, [256], [0, 256])
149 # cv2.calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate]])
150 plt.plot(hist)
151 plt.show()
685def plot_probabilities_histogram(Y):
686 plt.hist(Y, bins=10)
687 plt.xlabel("Probability of SPAM")
688 plt.ylabel("Number of data points")
689 plt.show()

Related snippets