我做了一个抖动函数,让我的数据变得像一棵圣诞树,我没有改变Y轴上的数据;我只是在x轴上添加一些随机性,这意味着什么,因为x轴是像Cell1,Cell2这样的独立条件。
def hist_jitter(data, xpos = 0, width = 0.8 , s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, label=None, bins=100, **kwargs ):
import numpy as np
counts, edges = np.histogram(data, bins=bins)
centres = (edges[:-1] + edges[1:]) / 2.
yvals = centres.repeat(counts)
max_offset = width / counts.max()
offsets = np.hstack((np.arange(cc) - 0.5 * (cc - 1)) for cc in counts)
xvals = xpos + (offsets * max_offset)
return ax.scatter(xvals, yvals, s=s, c=c, marker=marker, cmap=cmap, norm=norm, vmin=vmin, vmax=vmax, alpha=alpha, linewidths=linewidths, verts=verts, hold=hold,label=label, **kwargs)e here
我也有基于圣诞树功能的直方图
def break_me():
f, axis = plt.subplots(2,sharex=True,facecolor='w')
for ax in axis:
ax.tick_params(top=False, bottom=False, right=False)
ax.spines['bottom'].set_position('zero')
for sp in ['top','right','bottom']:
axis[0].spines[sp].set_visible(False)
for sp in ['top','right']:
axis[1].spines[sp].set_visible(False)
return f, axis
但是我需要打破我的y轴[0,90],然后是[120-140]:
as.Date(NA)
如何调用viol_jitter函数并决定在轴[0]或轴[0]中绘图?
谢谢! JM