本文整理汇总了Python中matplotlib.pyplot.Line2D方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.Line2D方法的具体用法?Python pyplot.Line2D怎么用?Python pyplot.Line2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.Line2D方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawComplex
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def drawComplex(data, ph, axes=[-6, 8, -6, 6]):
plt.clf()
plt.axis(axes) # axes = [x1, x2, y1, y2]
plt.scatter(data[:, 0], data[:, 1]) # plotting just for clarity
for i, txt in enumerate(data):
plt.annotate(i, (data[i][0] + 0.05, data[i][1])) # add labels
# add lines for edges
for edge in [e for e in ph.ripsComplex if len(e) == 2]:
# print(edge)
pt1, pt2 = [data[pt] for pt in [n for n in edge]]
# plt.gca().add_line(plt.Line2D(pt1,pt2))
line = plt.Polygon([pt1, pt2], closed=None, fill=None, edgecolor='r')
plt.gca().add_line(line)
# add triangles
for triangle in [t for t in ph.ripsComplex if len(t) == 3]:
pt1, pt2, pt3 = [data[pt] for pt in [n for n in triangle]]
line = plt.Polygon([pt1, pt2, pt3], closed=False,
color="blue", alpha=0.3, fill=True, edgecolor=None)
plt.gca().add_line(line)
plt.show()
示例2: drawComplex
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def drawComplex(origData, ripsComplex, axes=[-6,8,-6,6]):
plt.clf()
plt.axis(axes)
plt.scatter(origData[:,0],origData[:,1]) #plotting just for clarity
for i, txt in enumerate(origData):
plt.annotate(i, (origData[i][0]+0.05, origData[i][1])) #add labels
#add lines for edges
for edge in [e for e in ripsComplex if len(e)==2]:
#print(edge)
pt1,pt2 = [origData[pt] for pt in [n for n in edge]]
#plt.gca().add_line(plt.Line2D(pt1,pt2))
line = plt.Polygon([pt1,pt2], closed=None, fill=None, edgecolor='r')
plt.gca().add_line(line)
#add triangles
for triangle in [t for t in ripsComplex if len(t)==3]:
pt1,pt2,pt3 = [origData[pt] for pt in [n for n in triangle]]
line = plt.Polygon([pt1,pt2,pt3], closed=False, color="blue",alpha=0.3, fill=True, edgecolor=None)
plt.gca().add_line(line)
plt.show()
示例3: _draw_fusion_junction
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def _draw_fusion_junction(self, junction_location):
junction_location_norm = junction_location/float(self.normalize)*0.9
self.ax.add_line(plt.Line2D(
(
self.offset+junction_location_norm,
self.offset+junction_location_norm
),
(0.15+self.vertical_offset, 0.2+self.vertical_offset),
color='black'
)
)
self.right_marker_text = self.ax.text(
self.offset+junction_location_norm,
0.05+self.vertical_offset,
str(junction_location/1000),
horizontalalignment='center',
fontsize=self.fontsize
)
示例4: __init__
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def __init__(self, pendulum_plant, refresh_period=(1.0/240),
name='PendulumDraw'):
super(PendulumDraw, self).__init__(pendulum_plant,
refresh_period, name)
l = self.plant.l
m = self.plant.m
self.mass_r = 0.05*np.sqrt(m) # distance to corner of bounding box
self.center_x = 0
self.center_y = 0
# initialize the patches to draw the pendulum
self.pole_line = plt.Line2D((self.center_x, 0), (self.center_y, l),
lw=2, c='r')
self.mass_circle = plt.Circle((0, l), self.mass_r, fc='y')
示例5: _draw_maze_
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def _draw_maze_(maze_env, ax):
"""
The function to draw maze environment
Arguments:
maze_env: The maze environment configuration.
ax: The figure axis instance
"""
# draw maze walls
for wall in maze_env.walls:
line = plt.Line2D((wall.a.x, wall.b.x), (wall.a.y, wall.b.y), lw=1.5)
ax.add_line(line)
# draw start point
start_circle = plt.Circle((maze_env.agent.location.x, maze_env.agent.location.y),
radius=2.5, facecolor=(0.6, 1.0, 0.6), edgecolor='w')
ax.add_patch(start_circle)
# draw exit point
exit_circle = plt.Circle((maze_env.exit_point.x, maze_env.exit_point.y),
radius=2.5, facecolor=(1.0, 0.2, 0.0), edgecolor='w')
ax.add_patch(exit_circle)
示例6: add_legend_to_categorical_vector
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def add_legend_to_categorical_vector(
colors: np.ndarray, labels, ax, loc='best', # bbox_to_anchor=(0.98, 0.5),
markerscale=0.75, **kwargs):
"""
Add a legend to a plot where the color scale was set by discretizing a colormap.
:param colors: np.ndarray, output of map_categorical_vector_to_cmap()
:param labels: np.ndarray, category labels
:param ax: axis on which the legend should be plotted
:param kwargs: additional kwargs for legend
:return: None
"""
artists = []
for c in colors:
artists.append(plt.Line2D((0, 1), (0, 0), color=c, marker='o', linestyle=''))
ax.legend(
artists, labels, loc=loc, markerscale=markerscale, # bbox_to_anchor=bbox_to_anchor,
**kwargs)
示例7: display_roi
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def display_roi(self, **linekwargs):
line = plt.Line2D(self.x + [self.x[0]], self.y + [self.y[0]],
color=self.color, **linekwargs)
ax = plt.gca()
ax.add_line(line)
plt.draw()
示例8: vis_detections
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def vis_detections(im, class_name, dets, thresh=0.5, text=False):
"""Draw detected bounding boxes."""
inds = np.where(dets[:, -1] >= thresh)[0]
if len(inds) == 0:
return
im = im[:, :, (2, 1, 0)]
fig, ax = plt.subplots(figsize=(12, 12))
ax.imshow(im, aspect='equal')
for i in inds:
bbox = dets[i, :8]
score = dets[i, -1]
ax.add_line(
plt.Line2D([bbox[0], bbox[2], bbox[6], bbox[4], bbox[0]],
[bbox[1], bbox[3], bbox[7], bbox[5], bbox[1]],
color='red', linewidth=3)
)
if text:
ax.text(bbox[0], bbox[1] - 2,
'{:s} {:.3f}'.format(class_name, score),
bbox=dict(facecolor='blue', alpha=0.5),
fontsize=14, color='white')
ax.set_title(('{} detections with '
'p({} | box) >= {:.1f}').format(class_name, class_name,
thresh),
fontsize=14)
plt.axis('off')
plt.tight_layout()
plt.draw()
plt.show()
示例9: _draw_main_body
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def _draw_main_body(self, name_symbols, name_isoform):
"""
main protein frame
"""
length = (self.ensembl_transcript.end-self.ensembl_transcript.start)/float(self.normalize)*0.9
self.ax.add_line(plt.Line2D(
(
self.offset,
self.offset+length
),
(0.5, 0.5),
color='black'
)
)
self.ax.text(
0.5,
0.9,
name_symbols,
horizontalalignment='center',
fontsize=self.fontsize
)
self.ax.text(
0.5,
0.83,
name_isoform,
horizontalalignment='center',
fontsize=self.fontsize-3
)
示例10: draw
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def draw(self):
line = pyplot.Line2D((self.x1, self.x2), (self.y1, self.y2), lw=fabs(self.weight), color=get_synapse_colour(self.weight), zorder=1)
outer_glow = pyplot.Line2D((self.x1, self.x2), (self.y1, self.y2), lw=(fabs(self.weight) * 2), color=get_synapse_colour(self.weight), zorder=2, alpha=self.signal * 0.4)
pyplot.gca().add_line(line)
pyplot.gca().add_line(outer_glow)
示例11: test_add_artist
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def test_add_artist(fig_test, fig_ref):
fig_test.set_dpi(100)
fig_ref.set_dpi(100)
ax = fig_test.subplots()
l1 = plt.Line2D([.2, .7], [.7, .7], gid='l1')
l2 = plt.Line2D([.2, .7], [.8, .8], gid='l2')
r1 = plt.Circle((20, 20), 100, transform=None, gid='C1')
r2 = plt.Circle((.7, .5), .05, gid='C2')
r3 = plt.Circle((4.5, .8), .55, transform=fig_test.dpi_scale_trans,
facecolor='crimson', gid='C3')
for a in [l1, l2, r1, r2, r3]:
fig_test.add_artist(a)
l2.remove()
ax2 = fig_ref.subplots()
l1 = plt.Line2D([.2, .7], [.7, .7], transform=fig_ref.transFigure,
gid='l1', zorder=21)
r1 = plt.Circle((20, 20), 100, transform=None, clip_on=False, zorder=20,
gid='C1')
r2 = plt.Circle((.7, .5), .05, transform=fig_ref.transFigure, gid='C2',
zorder=20)
r3 = plt.Circle((4.5, .8), .55, transform=fig_ref.dpi_scale_trans,
facecolor='crimson', clip_on=False, zorder=20, gid='C3')
for a in [l1, r1, r2, r3]:
ax2.add_artist(a)
示例12: __line_between_two_neurons
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def __line_between_two_neurons(self, neuron1, neuron2):
angle = atan((neuron2.x - neuron1.x) / float(neuron2.y - neuron1.y))
x_adjustment = neuron_radius * sin(angle)
y_adjustment = neuron_radius * cos(angle)
line = pyplot.Line2D((neuron1.x - x_adjustment, neuron2.x + x_adjustment), (neuron1.y - y_adjustment, neuron2.y + y_adjustment))
pyplot.gca().add_line(line)
示例13: __init__
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def __init__(self, double_cartpole_plant, refresh_period=(1.0/240),
name='DoubleCartpoleDraw'):
super(DoubleCartpoleDraw, self).__init__(double_cartpole_plant,
refresh_period, name)
m1 = self.plant.m1
m2 = self.plant.m2
M = self.plant.M
l1 = self.plant.l1
l2 = self.plant.l2
self.body_h = 0.5*np.sqrt(m1)
self.mass_r1 = 0.05*np.sqrt(m2) # distance to corner of bounding box
self.mass_r2 = 0.05*np.sqrt(M) # distance to corner of bounding box
self.center_x = 0
self.center_y = 0
# initialize the patches to draw the cartpole
self.body_rect = plt.Rectangle((self.center_x - 0.5*self.body_h,
self.center_y - 0.125*self.body_h),
self.body_h, 0.25*self.body_h,
facecolor='black')
self.pole_line1 = plt.Line2D((self.center_x, 0),
(self.center_y, l1), lw=2, c='r')
self.mass_circle1 = plt.Circle((0, l1), self.mass_r1, fc='y')
self.pole_line2 = plt.Line2D((self.center_x, 0),
(l1, l2), lw=2, c='r')
self.mass_circle2 = plt.Circle((0, l1+l2), self.mass_r2, fc='y')
示例14: init_artists
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def init_artists(self):
plt.figure(self.name)
# initialize the patches to draw the cartpole
l = self.plant.l
cart_xy = (self.center_x-0.5*self.cart_h,
self.center_y-0.125*self.cart_h)
self.cart_rect = plt.Rectangle(cart_xy, self.cart_h,
0.25*self.cart_h, facecolor='black')
self.pole_line = plt.Line2D((self.center_x, 0), (self.center_y, l),
lw=2, c='r')
self.mass_circle = plt.Circle((0, l), self.mass_r, fc='y')
self.ax.add_patch(self.cart_rect)
self.ax.add_patch(self.mass_circle)
self.ax.add_line(self.pole_line)
示例15: init_artists
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import Line2D [as 别名]
def init_artists(self):
plt.figure(self.name)
self.lines = [plt.Line2D(self.t_labels, self.data[:, i],
c=next(color_generator)[0])
for i in range(self.data.shape[1])]
self.ax.set_aspect('auto', 'datalim')
for line in self.lines:
self.ax.add_line(line)
self.previous_update_time = time()