4 examples of 'pandas hist title' in Python

Every line of 'pandas hist title' 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
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
95def fig_hist(da, bins, title, condi=None, outside=(False, True),
96 colors=('#8ecbad', '#b3ffd9')):
97 density, edges = dens_hist(da, bins, outside)
98
99 if condi is None:
100 fig = draw_hist(edges, density)
101 else:
102 density2, edges2 = dens_hist(da[condi], bins, outside)
103
104 bar1 = go.Bar(
105 y=edges2, x=density2, orientation='h',
106 marker=dict(color='black', line=dict(color='black'))
107 )
108 bar2 = go.Bar(
109 y=edges, x=density, orientation='h',
110 marker=dict(
111 color='rgba(0,0,0,0)',
112 line=dict(color='white', width=1)
113 )
114 )
115 fig = go.Figure(data=[bar1, bar2])
116
117 density = density2
118 edges = edges2
119
120 format_hist(fig, bins, edges, density, title, outside, colors)
121
122 return fig
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()
113def pandas_group_hist_plot(df, var, group, x_name, y_name, folder='figures', save=True):
114 plt.figure(figsize=(8, 5))
115 g = sns.FacetGrid(df, hue=group, height=5, aspect=1)
116 g.map(sns.distplot, var)
117 g.add_legend()
118 plt.xlabel(x_name)
119 plt.ylabel(y_name)
120 plt.tight_layout()
121 if save:
122 plt.savefig("{0}/{1}_hist.pdf".format(folder, y_name), format="pdf")
123 else:
124 plt.show()
125 plt.close()

Related snippets