本文整理汇总了Python中matplotlib.patches.PathPatch类的典型用法代码示例。如果您正苦于以下问题:Python PathPatch类的具体用法?Python PathPatch怎么用?Python PathPatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PathPatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _draw
def _draw(self, renderer, bboxes, ticklabels_bbox):
renderer.open_group('coordinate_axis')
self._update_ticks(renderer)
self.ticks.draw(renderer)
self.ticklabels.draw(renderer, bboxes=bboxes,
ticklabels_bbox=ticklabels_bbox)
if self.grid_lines_kwargs['visible']:
if self._grid_type == 'lines':
self._update_grid_lines()
else:
self._update_grid_contour()
if self._grid_type == 'lines':
frame_patch = self.frame.patch
for path in self.grid_lines:
p = PathPatch(path, **self.grid_lines_kwargs)
p.set_clip_path(frame_patch)
p.draw(renderer)
elif self._grid is not None:
for line in self._grid.collections:
line.set(**self.grid_lines_kwargs)
line.draw(renderer)
renderer.close_group('coordinate_axis')
开发者ID:Cadair,项目名称:wcsaxes,代码行数:32,代码来源:coordinate_helpers.py
示例2: draw_box_with_text
def draw_box_with_text(ax, x, y, width, height, text, color='black', zorder=3, text_fontsize=15,
text_color="black", edgecolor='black', linewidth=4, linestyle=None):
alignment = {'horizontalalignment': 'center', 'verticalalignment': 'center'}
font_1 = font_0.copy()
font_1.set_size(text_fontsize)
font_1.set_weight('bold')
codes = [Path.MOVETO] + [Path.LINETO] * 3 + [Path.CLOSEPOLY]
vertices = [(x, y), (x + width, y), (x + width, y - height), (x, y - height), (0, 0)]
vertices = np.array(vertices, float)
path = Path(vertices, codes)
pathpatch = PathPatch(
path, #facecolor='None',
edgecolor=edgecolor, zorder=zorder,# lw=linewidth,
linewidth=linewidth, linestyle=linestyle
)
pathpatch.set_fill(False)
ax.text(x + width / 2.0, y - height / 2.0,
text,
color=text_color,
fontproperties=font_1,
**alignment)
ax.add_patch(pathpatch)
开发者ID:TEAM-HRA,项目名称:hra_suite,代码行数:25,代码来源:poincare_windows_5_min.py
示例3: join_lines
def join_lines(ax, min_idx, max_idx, y, color='black'):
codes = [Path.MOVETO] + [Path.LINETO]
vertices = [(min_idx, y), (max_idx, y)]
vertices = np.array(vertices, float)
path = Path(vertices, codes)
pathpatch = PathPatch(path, facecolor='None', edgecolor=color, zorder=3, lw=4)
pathpatch.set_fill(False)
ax.add_patch(pathpatch)
开发者ID:TEAM-HRA,项目名称:hra_suite,代码行数:8,代码来源:poincare_windows_5_min.py
示例4: draw_line_1
def draw_line_1(ax, idx, y_min, y_max, color='black', zorder=3):
codes = [Path.MOVETO] + [Path.LINETO]
vertices = [(idx, y_max), (idx, y_min)]
vertices = np.array(vertices, float)
path = Path(vertices, codes)
pathpatch = PathPatch(path, facecolor='None', edgecolor=color, zorder=zorder, lw=4)
pathpatch.set_fill(False)
ax.add_patch(pathpatch)
开发者ID:TEAM-HRA,项目名称:hra_suite,代码行数:8,代码来源:poincare_windows_5_min.py
示例5: hash_fill_between
def hash_fill_between(ax, x, y1, y2=0, **kargs):
''' For x, hash region between y1 and y2. Equivalent of ax.fill_between '''
p = ax.fill_between(x, y1, y2, **kargs)
p.set_facecolors("none")
p.set_edgecolors("none")
for path in p.get_paths():
p1 = PathPatch(path, fc="none", hatch="//", alpha=1)
ax.add_patch(p1)
p1.set_zorder(p.get_zorder() - 0.1)
开发者ID:flomertens,项目名称:libwise,代码行数:10,代码来源:plotutils_base.py
示例6: make_path
def make_path(d, style):
items = []
for c in d.split():
if c.upper() in codemap:
items.append(c)
else:
x, y = (float(v) for v in c.split(","))
items.append((x, y))
codes = []
vertices = []
i = 0
lx, ly = 0, 0
last_code = "M"
while i < len(items):
code = items[i]
if not isinstance(code, str):
code = last_code
else:
i += 1
ucode = code.upper()
if code.isupper():
relative = False
else:
relative = True
if ucode in ("M", "L"):
x, y = items[i]
i += 1
if relative:
x += lx
y += ly
codes.append(codemap[ucode])
vertices.append((x, y))
lx, ly = x, y
if ucode == "C":
if not relative:
points = items[i:i+3]
else:
points = [(_x + lx, _y + ly) for _x, _y in items[i:i+3]]
codes.extend([codemap[ucode]]*3)
vertices.extend(points)
lx, ly = points[-1]
i += 3
if ucode == "Z":
break
last_code = code
codes[0] = Path.MOVETO
patch = PathPatch( Path(vertices, codes) )
patch.set_linewidth( get_number(style.get("stroke-width", "1px") ) )
fill = style.get("fill", "none")
if fill == "none":
patch.set_fill( None )
else:
patch.set_facecolor( fill )
edge = style.get("stroke", "none")
patch.set_edgecolor(edge)
return patch
开发者ID:hejibo,项目名称:scpy2,代码行数:58,代码来源:svg_path.py
示例7: draw
def draw(fig, h, heid, row):
ax = plt.subplot2grid(shape=(2,5), loc=(row,0), colspan=2)
lbls = labels_count if row==1 else [_]
ax.set_xticklabels(lbls)
for t in ax.xaxis.get_major_ticks():
t.label.set_rotation(30)
rplt.hist(h, axes=ax)
npass = sum(list(h)[2:])
p = plt.fill_between([1.5,4.5],[npass,npass], [0.01,0.01])
p.set_facecolors('none')
for path in p.get_paths():
p1 = PathPatch(path, fc='none', hatch='\\\\\\', color='blue')
ax.add_patch(p1)
p1.set_zorder(p.get_zorder()-0.1)
ax.set_yscale('log')
ylim((0.01,3*h.GetMaximum()))
text(0.9, 0.75,'charge skim', fontsize=12, color='blue',
transform=ax.transAxes, horizontalalignment='right', verticalalignment='bottom')
text(0.9, 0.68, '%.1f'%(100*npass)+'$\%$', fontsize=14, color='blue',
transform=ax.transAxes, horizontalalignment='right', verticalalignment='top')
ax = plt.subplot2grid(shape=(2,5), loc=(row,2), colspan=3)
lbls = labels_eid if row==1 else [_]
ax.set_xticklabels(lbls)
for t in ax.xaxis.get_major_ticks():
t.label.set_rotation(30)
rplt.hist(heid, axes=ax)
X = [0.5,6.5]
Y1 = [npass,npass]
Y2 = [heid.GetMinimum(), heid.GetMinimum()]
# plot(X, Y2, 'r-.')
p = plt.fill_between([0.5,1.5],[npass,npass])
p.set_facecolors('none')
for path in p.get_paths():
p1 = PathPatch(path, fc='none', hatch='\\\\\\', color='blue')
ax.add_patch(p1)
p1.set_zorder(p.get_zorder()-0.1)
p = plt.fill_between([5.5,6.5],Y2)
p.set_facecolors('none')
for path in p.get_paths():
p1 = PathPatch(path, fc='none', hatch='xxx', color='green')
ax.add_patch(p1)
p1.set_zorder(p.get_zorder()-0.1)
ylim((0.5*heid.GetMinimum(),1.1*heid.GetMaximum()))
text(0.95, 0.75, 'refined electron\nidentification', fontsize=12, color='green',
transform=ax.transAxes, horizontalalignment='right', verticalalignment='bottom')
text(0.95, 0.68, '%.1f'%(100*heid.GetMinimum())+'$\%$', fontsize=14, color='green',
transform=ax.transAxes, horizontalalignment='right', verticalalignment='top')
# subplots_adjust(bottom=0.5, wspace=0.6, hspace=0.1)
subplots_adjust(left=0.1, bottom=0.15, wspace=0.6, hspace=0.1)
if row==1: # text(0,-0.0025,'selection criteria', fontsize=12)
text(0.5,0,'selection criteria', fontsize=12, transform=fig.transFigure, horizontalalignment='center')
text(0, 0.5, 'events per trigger', fontsize=12, transform=fig.transFigure, verticalalignment='center', rotation=90)
开发者ID:evan-phelps,项目名称:phys-ana-omega,代码行数:54,代码来源:skim.py
示例8: getResPatchInPrb
def getResPatchInPrb(self, n__PRB:int):
"""
get pathPatches for plot res in dedicate Prb
:return:
"""
codes = []
vertices = []
for re in self.prb(n__PRB)().res:
codes += re().codes
vertices += re().vertices
path = Path(vertices, codes)
pathPatch = PathPatch(path, facecolor='white', edgecolor='black', linewidth=0.2, linestyle='dotted', fill='none')
pathPatch.set_zorder(9)
return pathPatch
开发者ID:shennjia,项目名称:weblte,代码行数:15,代码来源:RG.py
示例9: getResPatchInReg
def getResPatchInReg(self, k___singleQuote:int, l___singleQuote:int):
"""
get pathPatches for plot res in dedicate Prb
:return:
"""
codes = []
vertices = []
for re in self.reg(k___singleQuote,l___singleQuote).res:
codes += re().codes
vertices += re().vertices
path = Path(vertices, codes)
patch = PathPatch(path, facecolor='white', edgecolor='black', linewidth=0.2, linestyle='dotted', fill='none')
patch.set_zorder(90)
return patch
开发者ID:shennjia,项目名称:weblte,代码行数:15,代码来源:RG.py
示例10: _initPatch
def _initPatch(self):
"""
get pathPatches for plotting res for CRS of dedicate port
:return:
"""
codes = []
vertices = []
for re in self.res:
codes += re().codes
vertices += re().vertices
path = Path(vertices, codes)
patch = PathPatch(path, facecolor='white', edgecolor='black', linewidth=0.2, fill='none')
patch.set_zorder(90)
return patch, codes, vertices
开发者ID:shennjia,项目名称:weblte,代码行数:15,代码来源:MBSFNRS.py
示例11: _initPatch
def _initPatch(self, n__s:int, subFrameTypeName:str):
"""
generate path patch for this PRB
:param n__s:
:param subFrameTypeName:
:return:
"""
vertices = []
codes = []
bottom = 0
left = 0
width = 0
height = 0
if subFrameTypeName == 'D':
bottom = self.n__PRB * conf.N__sc___RB_DL
left = 0
width = conf.N__symb___DL
height = conf.N__sc___RB_DL
if subFrameTypeName == 'U':
bottom = self.n__PRB * conf.N__sc___RB_UL
left = 0
width = conf.N__symb___UL
height = conf.N__sc___RB_UL
if subFrameTypeName == 'S':
if n__s %1 == 0:
bottom = self.n__PRB * conf.N__sc___RB_DL
left = 0
width = conf.N__symb___DwPTS
height = conf.N__sc___RB_DL
if n__s %1 == 1:
bottom = self.n__PRB * conf.N__sc___RB_UL
left = conf.N__symb___UpPTS
width = conf.N__symb___UL - conf.N__symb___DwPTS
height = conf.N__sc___RB_UL
codes = [Path.MOVETO] + [Path.LINETO]*3 + [Path.CLOSEPOLY]
vertices = [(left,bottom),
(left,bottom+height),
(left+width,bottom+height),
(left+width,bottom),
(0,0)]
path = Path(vertices, codes)
patch = PathPatch(path, facecolor='white', edgecolor='black', linewidth=2.0, fill='none' )
patch.set_zorder(80)
return patch, codes, vertices
开发者ID:shennjia,项目名称:weblte,代码行数:48,代码来源:PRB.py
示例12: create_24_tachogram
def create_24_tachogram(gs1, row_number, timing, des1,
start_hour=None, stop_hour=None,
slice_color="black"):
max_timing = np.max(timing)
ax_24_tachogram = plt.subplot(gs1[row_number, :])
ax_24_tachogram.set_color_cycle(['blue'])
ax_24_tachogram.plot(timing, des1)
ax_24_tachogram.ticklabel_format(style='sci', axis='x', scilimits=(0, max_timing))
ax_24_tachogram.xaxis.set_ticks(np.arange(0, int(max_timing) + 1, 1))
ax_24_tachogram.set_xlim(0, max_timing)
font_1 = font_0.copy()
font_1.set_size('11')
font_1.set_weight('bold')
y_lim = ax_24_tachogram.get_ylim()[1]
if not start_hour == None:
codes = [Path.MOVETO] + [Path.LINETO] * 3 + [Path.CLOSEPOLY]
vertices = [(start_hour, y_lim - 20),
(stop_hour, y_lim - 20),
(stop_hour, 0),
(start_hour, 0), (0, 0)]
vertices = np.array(vertices, float)
path = Path(vertices, codes)
pathpatch = PathPatch(path, facecolor='None', edgecolor=slice_color, zorder=3, lw=3)
pathpatch.set_fill(False)
ax_24_tachogram.add_patch(pathpatch)
leg = ax_24_tachogram.legend(['$\mathbf{%s}$' % ("RR")], loc='upper left')
#change legend font properties
plt.setp(leg.get_texts(), fontsize='large')
plt.setp(leg.get_texts(), fontweight='bold')
ax_24_tachogram.set_xlabel(u"Czas [godziny]", fontproperties = font_1)
ax_24_tachogram.set_ylabel(u"RR [ms]", fontproperties = font_1)
tachogram_label_pos = 18
font_1 = font_0.copy()
font_1.set_size('18')
font_1.set_weight('bold')
ax_24_tachogram.text(tachogram_label_pos, y_lim - 200,
u"Tachogram - 24 godziny", fontproperties = font_1)
bold_ticks_labels(ax_24_tachogram)
return row_number + 1
开发者ID:TEAM-HRA,项目名称:hra_suite,代码行数:48,代码来源:schema_for_single_recording.py
示例13: __init__
def __init__(self, canvas, color, x, y0=None, y1=None, line_width=1.0, picker_width=5, line_style='-'):
"""
Init the marker.
:param canvas: A MPL canvas.
:param color: An MPL colour value
:param x: The x coordinate (data) of the marker.
:param y0: The y coordinate (data) of the bottom end of the marker. Default is None which means dynamically
set it to the current lowest y value displayed.
:param y1: The y coordinate (data) of the top end of the marker. Default is None which means dynamically
set it to the current highest y value displayed.
:param line_width: The line width (pixels).
:param picker_width: The picker sensitivity (pixels).
:param line_style: An MPL line style value.
"""
super(VerticalMarker, self).__init__()
self.ax = canvas.figure.get_axes()[0]
self.x = x
self.y0 = y0
self.y1 = y1
y0, y1 = self._get_y0_y1()
path = Path([(x, y0), (x, y1)], [Path.MOVETO, Path.LINETO])
self.patch = PathPatch(path, facecolor='None', edgecolor=color, picker=picker_width,
linewidth=line_width, linestyle=line_style, animated=True)
self.ax.add_patch(self.patch)
self.is_moving = False
开发者ID:mantidproject,项目名称:mantid,代码行数:25,代码来源:markers.py
示例14: _draw
def _draw(self, renderer, bboxes):
renderer.open_group('coordinate_axis')
self._update_ticks(renderer)
self._update_grid()
self.ticks.draw(renderer)
self.ticklabels.draw(renderer, bboxes=bboxes)
if self.grid_lines_kwargs['visible']:
for path in self.grid_lines:
p = PathPatch(path, **self.grid_lines_kwargs)
p.set_clip_path(self.frame.path, Affine2D())
p.draw(renderer)
renderer.close_group('coordinate_axis')
开发者ID:ejeschke,项目名称:wcsaxes,代码行数:16,代码来源:coordinate_helpers.py
示例15: initPatch
def initPatch(self):
"""
plot based on matplotlib
:return:
"""
vertices = []
codes = []
codes = [Path.MOVETO] + [Path.LINETO]*3 + [Path.CLOSEPOLY]
vertices = [(self.l,self.k),
((self.l),(self.k+1)),
((self.l+1),(self.k+1)),
((self.l+1),(self.k)),
(0,0)]
path = Path(vertices, codes)
patch = PathPatch(path, facecolor='white', edgecolor='black')
patch.set_zorder(100)
return patch, codes,vertices
开发者ID:shennjia,项目名称:weblte,代码行数:17,代码来源:RE.py
示例16: _initPatch
def _initPatch(self):
"""
generate path patch for this SLOT
:param n:
:param subFrameTypeName:
:return:
"""
vertices = []
codes = []
vertices += self.slots[0].vertices
codes += self.slots[0].codes
vertices += self.slots[1].vertices
codes += self.slots[1].codes
path = Path(vertices, codes)
patch = PathPatch(path, facecolor='white', edgecolor='black', linewidth=2.0, fill='none' )
patch.set_zorder(60)
return patch, codes, vertices
开发者ID:shennjia,项目名称:weblte,代码行数:18,代码来源:SUBFRAME.py
示例17: _add_ends
def _add_ends(self):
"""
Create patches from extended ends and add them to the axes.
"""
del self.extension_patch1
del self.extension_patch2
path1, path2 = self.ax.get_axes_locator().get_path_ends()
fc = mpl.rcParams["axes.facecolor"]
ec = mpl.rcParams["axes.edgecolor"]
linewidths = 0.5 * mpl.rcParams["axes.linewidth"]
self.extension_patch1 = PathPatch(
path1, fc=fc, ec=ec, lw=linewidths, zorder=2.0, transform=self.ax.transAxes, clip_on=False
)
self.extension_patch2 = PathPatch(
path2, fc=fc, ec=ec, lw=linewidths, zorder=2.0, transform=self.ax.transAxes, clip_on=False
)
self.ax.add_artist(self.extension_patch1)
self.ax.add_artist(self.extension_patch2)
开发者ID:NelleV,项目名称:matplotlib,代码行数:20,代码来源:colorbar.py
示例18: _sync_patch
def _sync_patch(self):
if self._patch is not None:
self._patch.remove()
self._patch = None
if self._roi.defined():
x, y = self._roi.to_polygon()
p = MplPath(np.column_stack((x, y)))
self._patch = PathPatch(p)
self._patch.set_visible(True)
self._patch.set(**self.plot_opts)
开发者ID:glue-viz,项目名称:glue,代码行数:12,代码来源:roi.py
示例19: MplPathROI
class MplPathROI(MplPolygonalROI):
def roi_factory(self):
return Path()
def _setup_patch(self):
self._patch = None
def _sync_patch(self):
if self._patch is not None:
self._patch.remove()
self._patch = None
# Update geometry
if not self._roi.defined():
return
else:
x, y = self._roi.to_polygon()
p = MplPath(np.column_stack((x, y)))
self._patch = PathPatch(p)
self._patch.set_visible(True)
# Update appearance
self._patch.set(**self.plot_opts)
# Refresh
self._axes.figure.canvas.draw()
def finalize_selection(self, event):
self._mid_selection = False
if self._patch is not None:
self._patch.set_visible(False)
self._axes.figure.canvas.draw()
开发者ID:saimn,项目名称:glue,代码行数:33,代码来源:roi.py
示例20: BezierHitTest
def BezierHitTest(path, x0, y0):
from matplotlib.patches import PathPatch
import ifigure.widgets.canvas.custom_picker as cpicker
segpath = BezierSplit(path)
i = 0
for seg in segpath:
p = [(item[0], item[1]) for item in seg]
codes, verts = zip(*p)
obj = matplotlib.path.Path(verts, codes)
a = PathPatch(obj)
xy= a.get_verts()
if len(xy) == 0: ## this case happens when verts has only two points in mpl1.5
x = [v[0] for v in verts]
y = [v[1] for v in verts]
else:
x = np.transpose(xy)[0]
y = np.transpose(xy)[1]
hit, idx = cpicker.CheckLineHit(x, y, x0, y0)
if hit: return True, i
i = i+1
return False, -1
开发者ID:piScope,项目名称:piScope,代码行数:22,代码来源:cbook.py
注:本文中的matplotlib.patches.PathPatch类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论