def plot_density(self, ax, num=300, **kwargs):
"""Returns a density plot on an Pyplot Axes object.
Args:
ax (:obj:`Axes`): An matplotlib Axes object on which the histogram will be plot
num (:obj:`int`): The number of x values the line is plotted on. Default: 300
**kwargs: Keyword arguments that are passed on to the pyplot.plot function.
"""
colors = []
self.build()
bin_centers = np.asarray(self._get_bin_centers())
x_new = np.linspace(bin_centers.min(), bin_centers.max(), num)
if 'color' in kwargs:
colors = kwargs['color']
del kwargs['color']
power_smooth = []
for (colname, bin_values) in self.hist_dict.items():
normed_values, ble = np.histogram(self._get_bin_centers(),
bins=self.bin_list,
weights=bin_values,
normed=True
)
power_smooth.append(x_new)
power_smooth.append(spline(bin_centers, normed_values, x_new))
lines = ax.plot(*power_smooth, **kwargs)
for i, line in enumerate(lines):
if len(colors) > 0:
plt.setp(line, color=colors[i], label=list(self.hist_dict.keys())[i])
else:
plt.setp(line, label=list(self.hist_dict.keys())[i])
return lines
pyspark_dist_explore.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录