本文整理汇总了Python中matplotlib.patches.Circle类的典型用法代码示例。如果您正苦于以下问题:Python Circle类的具体用法?Python Circle怎么用?Python Circle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Circle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: write_body
def write_body(self):
try:
from matplotlib.path import Path
except ImportError:
Path = None
from matplotlib.patches import Circle, Polygon
else:
from matplotlib.patches import Circle, PathPatch
indices = self.X[:, 2].argsort()
for a in indices:
xy = self.X[a, :2]
if a < self.natoms:
r = self.d[a] / 2
if ((xy[1] + r > 0) and (xy[1] - r < self.h) and
(xy[0] + r > 0) and (xy[0] - r < self.w)):
circle = Circle(xy, r, facecolor=self.colors[a])
circle.draw(self.renderer)
else:
a -= self.natoms
c = self.T[a]
if c != -1:
hxy = self.D[c]
if Path is None:
line = Polygon((xy + hxy, xy - hxy))
else:
line = PathPatch(Path((xy + hxy, xy - hxy)))
line.draw(self.renderer)
开发者ID:JConwayAWT,项目名称:PGSS14CC,代码行数:28,代码来源:eps.py
示例2: animate
def animate(currentNode = currentNode):
while 1:
newNode = q.get()
if currentNode: currentNode.remove()
circle = Circle(newNode,0.1)
currentNode = ax.add_patch(circle)
circle.set_fc('r')
fig.canvas.draw()
开发者ID:elkronopio,项目名称:python-view3D,代码行数:8,代码来源:visualMD.py
示例3: circle
def circle(xy=None, x=None, y=None, **kwargs):
if xy is None:
if x is None or y is None:
raise 'circle: need x and y'
xy = array([x,y])
c = Circle(xy=xy, **kwargs)
a=gca()
c.set_clip_box(a.bbox)
a.add_artist(c)
return c
开发者ID:blackball,项目名称:an-test6,代码行数:10,代码来源:plotutils.py
示例4: draw_vswr_circles
def draw_vswr_circles(self, vswr_radii, labels=False):
for r in vswr_radii:
c = Circle((0, 0), r, ls='dashed', **self.patch_options_light)
c.set_clip_path(self.smith_circle)
c.set_clip_box(self.ax.bbox)
self.ax.add_patch(c)
if labels:
for r in vswr_radii:
if r > 0:
vswr = (1 + r)/(1 - r)
self.ax.text(0, r, '%.1f' % vswr, **self.label_options)
开发者ID:fuesika,项目名称:PyTwoPort,代码行数:13,代码来源:smithplot.py
示例5: make_animation_frames
def make_animation_frames(name, semimajor, planet_radius, star_radius, star_color, orbital_period):
#not affiliated with Animal Planet.
center = np.array([0.5,0.5])
angle = np.random.uniform(0, 2*np.pi)
planet_center = center+semimajor*np.array([1,0])
fig = Figure(figsize=(6,6))
axis = fig.add_subplot(1, 1, 1)
star = Circle(center, radius=star_radius, color=star_color)
orbit = Circle(center, radius=semimajor, fill=False, linestyle='dashed', color='gray')
planet = Circle(planet_center, radius=planet_radius, color='green')
axis.add_patch(star)
axis.add_patch(orbit)
axis.add_patch(planet)
axis.axis('off')
filenames = []
#set 50 days to be 5 seconds
orbital_period = orbital_period/100.*5.
#let's put the period in seconds
fps = 100.
print 'orbital period = ', orbital_period
nframe = int(orbital_period*fps)
#round off
orbital_period = nframe/fps
omega = 2*np.pi/orbital_period
angles = np.linspace(0, 2*np.pi, nframe)
if not os.path.exists("frames"):
os.makekdir("frames")
if not os.path.exists("gifs"):
os.makekdir("gifss")
print angles
print "nframe = ", nframe
for i,theta in enumerate(angles):
canvas = FigureCanvas(fig)
planet.center = center+semimajor*np.array([np.cos(theta),np.sin(theta)])
filename = ("frames/%.4d_"%i)+remove_space(name)+'.png'
fig.savefig(filename)
filenames.append(filename)
#animate
gifname = "gifs/%s.gif" % remove_space(name)
frame_names = " ".join(filenames)
cmd = "convert -delay 1 %s %s" % (frame_names, gifname)
print cmd
os.system(cmd)
开发者ID:RuthAngus,项目名称:exoplanet_travel,代码行数:51,代码来源:exoplanet_pictograms.py
示例6: add_breadcrumb
def add_breadcrumb(self):
""" Adds a breadcrumb """
c = Circle(self._loc, radius = 16.25)
c.set_facecolor('0.65') # grey
c.set_edgecolor('black')
c.set_zorder(zorders['breadcrumbs'])
c.set_fill(True)
self.view.add_artist(c)
self.breadcrumbs.append(c)
self.draw()
开发者ID:dwtj,项目名称:mars-rover,代码行数:10,代码来源:rover.py
示例7: scatter_plot
def scatter_plot(self, equators=True, tagging=True, depth_cap=None):
if depth_cap is None:
depth_cap = self.height
fig = plt.figure(figsize=(12, 10))
ax = fig.add_subplot(111, projection="3d")
plt.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)
xs = [self.nodes[self.root].coord.x]
ys = [self.nodes[self.root].coord.y]
zs = [self.nodes[self.root].coord.z]
plot_color_board = ["blue", "red", "yellow", "green", "black"]
font0 = FontProperties()
font0.set_size(8)
current_generation = deque([self.root])
next_generation = True
while next_generation:
next_generation = deque()
while current_generation:
n = current_generation.popleft()
if self.nodes[n].depth <= depth_cap:
xs.append(self.nodes[n].coord.x)
ys.append(self.nodes[n].coord.y)
zs.append(self.nodes[n].coord.z)
if tagging:
ax.text(self.nodes[n].coord.x + 0.01,
self.nodes[n].coord.y + 0.01,
self.nodes[n].coord.z + 0.01,
("n{0}".format(n)), fontproperties=font0)
for child in self.nodes[n].children:
next_generation.append(child)
if self.nodes[n].depth <= depth_cap:
xe = [self.nodes[n].coord.x, self.nodes[child].coord.x]
ye = [self.nodes[n].coord.y, self.nodes[child].coord.y]
ze = [self.nodes[n].coord.z, self.nodes[child].coord.z]
ax.plot(xe, ye, ze, plot_color_board[self.nodes[n].depth % 5])
current_generation = next_generation
ax.scatter(xs, ys, zs, c="r", marker="o")
global_radius = self.nodes[self.root].radius * 1.12
if equators:
for axis in ["x", "y", "z"]:
circle = Circle((0, 0), global_radius * 1.1)
circle.set_clip_box(ax.bbox)
circle.set_edgecolor("gray")
circle.set_alpha(0.3)
circle.set_facecolor("none") # "none" not None
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0, zdir=axis)
ax.set_xlim([-1.2 * global_radius, 1.2 * global_radius])
ax.set_ylim([-1.2 * global_radius, 1.2 * global_radius])
ax.set_zlim([-1.2 * global_radius, 1.2 * global_radius])
ax.set_xlabel("X Label")
ax.set_ylabel("Y Label")
ax.set_zlabel("Z Label")
plt.show()
开发者ID:ee08b397,项目名称:hypy,代码行数:53,代码来源:tree.py
示例8: circle
def circle( xy, radius, color="lightsteelblue", facecolor="none", alpha=1, ax=None ):
""" add a circle to ax= or current axes
"""
# from .../pylab_examples/ellipse_demo.py
e = Circle( xy=xy, radius=radius )
if ax is None:
ax = plt.gca() # ax = subplot( 1,1,1 )
ax.add_artist(e)
e.set_clip_box(ax.bbox)
e.set_edgecolor( color )
e.set_facecolor( facecolor ) # "none" not None
e.set_alpha( alpha )
开发者ID:otherview,项目名称:wlanlist,代码行数:12,代码来源:trataDados.py
示例9: Annotate
class Annotate(object):
def __init__(self):
self.ax = plt.gca()
# self.rect = Rectangle((0,0), 1, 1)
self.circ = Circle((0,0), 1, alpha=0.1)
self.x0 = None
self.y0 = None
self.x1 = None
self.y1 = None
# self.ax.add_patch(self.rect)
self.ax.add_patch(self.circ)
self.press = None
self.ax.figure.canvas.mpl_connect('button_press_event', self.on_press)
self.ax.figure.canvas.mpl_connect('motion_notify_event', self.on_motion)
self.ax.figure.canvas.mpl_connect('button_release_event', self.on_release)
def on_press(self, event):
print 'press'
self.press = 1
self.x0 = event.xdata
self.y0 = event.ydata
def on_motion(self, event):
if self.press is None:
return
self.x1 = event.xdata
self.y1 = event.ydata
radius = ((self.x1 - self.x0)**2 + (self.y1 - self.y0)**2)**0.5
self.circ.set_radius(radius)
self.circ.center = self.x0, self.y0
# ###self.rect.set_width(self.x1 - self.x0)
# ###self.rect.set_height(self.y1 - self.y0)
# ###self.rect.set_xy((self.x0, self.y0))
self.ax.figure.canvas.draw()
def on_release(self, event):
print 'release'
self.press = None
self.x1 = event.xdata
self.y1 = event.ydata
radius = ((self.x1 - self.x0) ** 2 + (self.y1 - self.y0) ** 2) ** 0.5
self.circ.set_radius(radius)
self.circ.center = self.x0, self.y0
# ###self.rect.set_width(self.x1 - self.x0)
# ###self.rect.set_height(self.y1 - self.y0)
# ###self.rect.set_xy((self.x0, self.y0))
self.ax.figure.canvas.draw()
开发者ID:drolmaeye,项目名称:Diptera,代码行数:47,代码来源:drag_rectangle.py
示例10: __init__
def __init__(self, axes, sim, type_to_radius, type_to_color):
assert len(type_to_radius) == len(type_to_color)
particle_types_arr = sim.types
self._typeToRadius = type_to_radius
self._typeToColor = type_to_color
self._particleCircles = []
self._sim = sim
for particleType in particle_types_arr:
c = Circle((0, 0, 0), type_to_radius[particleType], )
c.set_color(self._typeToColor[particleType])
self._particleCircles.append(c)
axes.add_patch(c)
axes.set_xlim([0, sim.domain_size[0]])
axes.set_ylim([0, sim.domain_size[1]])
axes.set_aspect('equal')
开发者ID:mabau,项目名称:statistical_mechanics_teaching,代码行数:17,代码来源:mpl_display.py
示例11: __init__
class SelectablePoint:
def __init__(self, xy, label, fig):
self.point = Circle( (xy[0], xy[1]), .25, figure=fig)
self.label = label
self.cidpress = self.point.figure.canvas.mpl_connect('button_press_event', self.onClick)
def onClick(self, e):
if self.point.contains(e)[0]:
print self.label
开发者ID:cudmore,项目名称:mapmanager_ipynb,代码行数:9,代码来源:qt_matplotlib.py
示例12: draw_chart_axes
def draw_chart_axes(self):
# make outer circle
self.smith_circle = Circle((0, 0), 1, transform=self.ax.transData, fc='none',
**self.patch_options_axis)
self.ax.add_patch(self.smith_circle)
# make constant r=1 circle
z0_circle = Circle((0.5, 0), 0.5, transform=self.ax.transData, fc='none',
**self.patch_options_axis)
z0_circle.set_clip_path(self.smith_circle)
z0_circle.set_clip_box(self.ax.bbox)
self.ax.add_patch(z0_circle)
# make x-axis
line = Line2D([-1,1],[0,0], **self.patch_options_axis)
line.set_clip_path(self.smith_circle)
line.set_clip_box(self.ax.bbox)
self.ax.add_line(line)
开发者ID:fuesika,项目名称:PyTwoPort,代码行数:18,代码来源:smithplot.py
示例13: myCorrPlot
def myCorrPlot(df):
"""
Correlation plot ( ~ corrplot with R)
Takes a Pandas DataFrame as input and returns
the plot which can then be shown with
plot.show(), saved to a file with plot.savefig(), or
manipulated in any other standard matplotlib way.
Forked from https://github.com/louridas/corrplot
"""
plt.figure(1)
ax = plt.subplot(1, 1, 1, aspect='equal')
poscm = cm.get_cmap('Blues')
negcm = cm.get_cmap('Reds')
labels = df.columns
for pair in combinations(labels, 2):
corr = pearsonr(df[pair[0]].values, df[pair[1]].values)[0]
clrmap = poscm if corr >= 0 else negcm
circle = Circle((labels.get_loc(pair[0]),labels.get_loc(pair[1])), radius = 0.4)
circle.set_edgecolor('black')
circle.set_facecolor(clrmap(np.abs(corr)))
mirrorCircle = Circle((labels.get_loc(pair[1]),labels.get_loc(pair[0])), radius = 0.4)
mirrorCircle.set_edgecolor('black')
mirrorCircle.set_facecolor(clrmap(np.abs(corr)))
ax.add_artist(circle)
ax.add_artist(mirrorCircle)
ax.set_xlim(-1, len(labels))
ax.set_ylim(-1, len(labels))
ax.xaxis.tick_top()
xtickslocs = np.arange(len(labels))
ax.set_xticks(xtickslocs)
ax.set_xticklabels(labels, rotation=30, fontsize='small', ha='left')
ax.invert_yaxis()
ytickslocs = np.arange(len(labels))
ax.set_yticks(ytickslocs)
ax.set_yticklabels(labels, fontsize='small')
return plt
开发者ID:mazieres,项目名称:corrplot,代码行数:43,代码来源:corrplot.py
示例14: draw_impedance_circles
def draw_impedance_circles(self, intercept_x_coords, intercept_angles, labels=False):
r_circle_coords, x_circle_coords, rs, xs = self._impedance_circle_coords(intercept_x_coords, intercept_angles)
for center, radius in chain(r_circle_coords, x_circle_coords):
c = Circle(center, radius, **self.patch_options_dark)
c.set_clip_path(self.smith_circle)
c.set_clip_box(self.ax.bbox)
self.ax.add_patch(c)
if labels:
for x, r in zip(intercept_x_coords, rs):
self.ax.text(x + 0.04, 0.03, '%.0f' % round(self.z0*r), **self.label_options)
for a, x in zip(intercept_angles, xs):
r = (a - 90) if x > 0 else (a + 90)
a = np.radians(a)
d = 1.04
self.ax.text(d*cos(a), d*sin(a), '%.0fj' % round(self.z0*x), rotation=r, **self.label_options)
开发者ID:fuesika,项目名称:PyTwoPort,代码行数:20,代码来源:smithplot.py
示例15: draw_admittance_circles
def draw_admittance_circles(self, intercept_x_coords, intercept_angles, labels=False):
r_circle_coords, x_circle_coords, rs, xs = self._impedance_circle_coords(intercept_x_coords, intercept_angles)
# admittance circles have same coords as impedance ones, except flipped
# on the y-axis
for (x, y), radius in chain(r_circle_coords, x_circle_coords):
c = Circle((-x, -y), radius, **self.patch_options_light)
c.set_clip_path(self.smith_circle)
c.set_clip_box(self.ax.bbox)
self.ax.add_patch(c)
if labels:
for x, r in zip(intercept_x_coords, rs):
self.ax.text(-x, 0, '%.1f' % (1/(50*r)), **self.label_options)
for a, x in zip(intercept_angles, xs):
r = (a - 90) if x < 0 else (a + 90)
a = np.radians(a)
self.ax.text(cos(pi - a), sin(pi - a), '%.1f' % (1/(50*x)), rotation=r, **self.label_options)
开发者ID:fuesika,项目名称:PyTwoPort,代码行数:21,代码来源:smithplot.py
示例16: __init__
def __init__(self):
self.ax = plt.gca()
# self.rect = Rectangle((0,0), 1, 1)
self.circ = Circle((0,0), 1, alpha=0.1)
self.x0 = None
self.y0 = None
self.x1 = None
self.y1 = None
# self.ax.add_patch(self.rect)
self.ax.add_patch(self.circ)
self.press = None
self.ax.figure.canvas.mpl_connect('button_press_event', self.on_press)
self.ax.figure.canvas.mpl_connect('motion_notify_event', self.on_motion)
self.ax.figure.canvas.mpl_connect('button_release_event', self.on_release)
开发者ID:drolmaeye,项目名称:Diptera,代码行数:14,代码来源:drag_rectangle.py
示例17: shooting_plot
def shooting_plot(shot_df, plot_size=(12,11), gridNum=30, mymap=plt.get_cmap('Spectral')):
from matplotlib.patches import Circle
x = shot_df.LOC_X[shot_df['LOC_Y']<425.1]
y = shot_df.LOC_Y[shot_df['LOC_Y']<425.1]
(shotVals, shotNumber) = find_shot_vals(shot_df, gridNum)
fig = plt.figure(figsize=plot_size)
cmap = mymap
ax = plt.axes([0.1, 0.1, 0.8, 0.8])
draw_court(outer_lines=False)
plt.xlim(-250,250)
plt.ylim(422.5, -47.5)
norm = mpl.colors.Normalize(vmin=-0.5, vmax = -0.1)
import math
def logistic(x):
return 20 / (1 + math.exp(-0.18*(x-np.median(shotNumber.get_array()))))
for i, shots in enumerate(shotVals):
restricted = Circle(shotNumber.get_offsets()[i], radius=shotNumber.get_array()[i],
color=cmap(norm(shots)),alpha=0.8, fill=True)
restricted.radius = logistic( np.sqrt(restricted.radius) )
if restricted.radius > 240/gridNum: restricted.radius=240/gridNum
ax.add_patch(restricted)
ax2 = fig.add_axes([0.92, 0.1, 0.02, 0.8])
cb = mpl.colorbar.ColorbarBase(ax2,cmap=cmap, orientation='vertical')
cb.set_label('next-possession value')
cb.set_ticks([0.0, 0.25, 0.5, 0.75, 1.0])
cb.set_ticklabels(['-0.5','-0.4', '-0.3','-0.2', '-0.1'])
plt.show()
return ax
开发者ID:mikss,项目名称:coldmaps,代码行数:37,代码来源:draw.py
示例18: __init__
def __init__(self, vl, room_shape, start_iter):
super(EnvironmentReader,self).__init__(win_size=[700,700],
win_loc=pos,
title='Environment')
self.vl = vl
self.cur_iter = start_iter
self.cur_i = 0
self.max_iter = np.max(vl['Iter num'])
self.maxx = room_shape[0][1]
self.maxy = room_shape[1][1]
self.cntr_x = np.mean(room_shape[0])
self.cntr_y = np.mean(room_shape[1])
self.x_hist = []; self.y_hist = []
self.canvas.mpl_connect('resize_event',lambda x: self.update_background())
self.pos, = self.ax.plot([],[],color='g',animated=True)
self.vel = Arrow([0,0],[1,0],arrowstyle='-|>, head_length=3, head_width=3',
animated=True, linewidth=4)
self.ax.add_patch(self.vel)
#self.radius, = self.ax.plot([],[],color='r',animated=True)
self.clockcounter = self.ax.text(self.maxx,room_shape[1][0],
'',ha='right',size='large',
animated=True)
self.iters = self.ax.text(self.maxx-1, room_shape[1][0]+3,
'',ha='right',animated=True)
self.target = Circle([0,0],0,animated=True,color='r')
self.target.set_radius(11)
self.ax.add_artist(self.target)
self.ax.set_xlim(room_shape[0])
self.ax.set_ylim(room_shape[1])
self.draw_plc_flds()
self.draw_HMM_sectors()
self.predicted_counter = self.ax.text(self.maxx,room_shape[1][0]+10,'',
ha='right',size='large',animated=True)
self.prediction_hist = None
#self.cur_sec = Rectangle([0,0],self.HMM.dx,self.HMM.dy,fill=True,
# color='k',animated=True)
#self.ax_env.add_patch(self.cur_sec)
self.canvas.draw()
开发者ID:joel-shor,项目名称:Context-Classifier,代码行数:46,代码来源:EnvironmentReader.py
示例19: __init__
def __init__(self, cloud, selection_shape, z_color=False, unlabeled_color = (1,0,0), labeled_color = (0,0,1)):
self.selection_shape = selection_shape
self.unlabeled_color = np.array(unlabeled_color)
self.labeled_color = np.array(labeled_color)
assert not np.all(unlabeled_color == labeled_color)
self.fig = plt.figure('label rope ends', figsize=(24,12))
self.fig.clear()
self.ax = self.fig.add_subplot(111, aspect='equal')
if cloud.shape[1] == 6:
self.cloud = cloud
else:
self.cloud = np.c_[cloud[:,:3], np.tile(self.unlabeled_color, (cloud.shape[0],1))]
if z_color:
z_min = self.cloud[:,2].min()
z_max = self.cloud[:,2].max()
self.z_color = np.empty((len(self.cloud),3))
for i in range(len(self.cloud)):
f = (self.cloud[i,2] - z_min) / (z_max - z_min)
self.z_color[i,:] = np.array(colorsys.hsv_to_rgb(f,1,1))
else:
self.z_color = None
self.scatters = []
self.rescatter_cloud()
self.ax.autoscale(False)
if self.selection_shape == 'rectangle' or self.selection_shape == 'square':
self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='green', linestyle='dashed')
self.ax.add_patch(self.rect)
elif self.selection_shape == 'circle':
self.circle = Circle((0,0), 0, facecolor='None', edgecolor='green', linestyle='dashed')
self.ax.add_patch(self.circle)
self.x0 = None
self.y0 = None
self.x1 = None
self.y1 = None
self.fig.canvas.mpl_connect('button_press_event', self.on_press)
self.fig.canvas.mpl_connect('button_release_event', self.on_release)
self.motion_notify_cid = None
self.fig.canvas.mpl_connect('key_press_event', self.on_key)
plt.show()
开发者ID:shhuang,项目名称:jointopt-lfd,代码行数:45,代码来源:label_clouds.py
示例20: enable_cursor
def enable_cursor(self):
self.cid_on_mouse_move = self.fig.canvas.mpl_connect('motion_notify_event', self._on_mouse_move)
self.fig.canvas.mpl_connect('button_press_event', self._on_mouse_press)
#self.cid_on_mouse_leave = self.fig.canvas.mpl_connect('axes_leave_event', self._on_mouse_leave)
#self.cid_resize = self.fig.canvas.mpl_connect('resize_event', self._resize)
self.cid_draw = self.fig.canvas.mpl_connect('draw_event', self._draw)
self.cursor_text = Text(0.7, 0.1, 'n/a',
horizontalalignment='left',
verticalalignment='center',
#bbox=dict(facecolor='white', alpha=1, ec='gray', pad=10),
color='white',
fontsize='small',
alpha=0.8,
backgroundcolor='gray',
family='monospace',
clip_box=self.ax.bbox,
animated=True,
transform = self.ax.transAxes)
self.ax.add_artist(self.cursor_text)
self.circle_matched_term = Circle((100,100), 0.02, alpha=0.5, color='green', animated=True)
self.ax.add_patch(self.circle_matched_term)
开发者ID:fuesika,项目名称:PyTwoPort,代码行数:23,代码来源:smithplot.py
注:本文中的matplotlib.patches.Circle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论