def add_markers(self, ax=None, where=0.0, orientation='horizontal',
jitter=0, **kwargs):
if ax is None:
ax = plt.gca()
# draw the positions
if 'marker' not in kwargs:
if orientation == 'horizontal':
kwargs['marker'] = '|'
else:
kwargs['marker'] = '_'
if ('facecolor' not in kwargs.keys()) | ('fc' not in kwargs.keys()) | \
('markerfacecolor' not in kwargs.keys()) | ('mfc' not in kwargs.keys()):
kwargs['markerfacecolor'] = 'None'
if ('edgecolor' not in kwargs.keys()) | ('ec' not in kwargs.keys()) | \
('markeredgecolor' not in kwargs.keys()) | ('mec' not in kwargs.keys()):
kwargs['markeredgecolor'] = 'k'
if ('linestyle' not in kwargs.keys()) | ('ls' not in kwargs.keys()):
kwargs['linestyle'] = 'None'
if ('size' not in kwargs.keys()) | ('markersize' not in kwargs.keys()):
kwargs['markersize'] = 3
if orientation == 'horizontal':
# Draw the lines
if jitter > 0:
pos = np.random.uniform(low=float(where - jitter),
high=float(where + jitter),
size=len(self.x))
ax.plot(self.x, pos, **kwargs)
else:
ax.plot(self.x, float(where) * np.ones(len(self.x)), **kwargs)
plt.draw_if_interactive()
elif orientation == 'vertical':
# Draw the lines
if jitter > 0.:
pos = np.random.uniform(low=float(where - jitter),
high=float(where + jitter),
size=len(self.x))
ax.plot(pos, self.x, **kwargs)
else:
ax.plot(float(where) * np.ones(len(self.x)), self.x, marker='_',
**kwargs)
plt.draw_if_interactive()
评论列表
文章目录