本文整理汇总了Python中matplotlib.patches.Polygon.set_facecolor方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.set_facecolor方法的具体用法?Python Polygon.set_facecolor怎么用?Python Polygon.set_facecolor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Polygon
的用法示例。
在下文中一共展示了Polygon.set_facecolor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotReachSet_norm1
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_facecolor [as 别名]
def plotReachSet_norm1(self, NUM, figname):
fig = p.figure()
for j in range(n):
ax = fig.add_subplot(2,2,j+1 , aspect='equal')
ax.set_xlim(0, 4)
ax.set_ylim(0, 1)
ax.set_xlabel('$x_'+str(j+1)+'$')
ax.set_ylabel('$y_'+str(j+1)+'$')
for trace in self:
for i in [int(floor(k*len(trace.T)/NUM)) for k in range(NUM)]:
verts = [(trace.x[i][j] + 1/trace.d_norm1[i][2*j], trace.y[i][j] ),
(trace.x[i][j] , trace.y[i][j] - 1/trace.d_norm1[i][2*j+1]),
(trace.x[i][j] - 1/trace.d_norm1[i][2*j], trace.y[i][j] ),
(trace.x[i][j] , trace.y[i][j] + 1/trace.d_norm1[i][2*j+1])]
# poly = Ellipse((trace.x[i][j],trace.y[i][j]), width=trace.d1[i], height=trace.d2[i], angle=trace.theta[i])
poly = Polygon(verts, facecolor='0.8', edgecolor='k')
ax.add_artist(poly)
poly.set_clip_box(ax.bbox)
poly.set_alpha(1)
if i==0:
poly.set_facecolor('r')
else:
poly.set_facecolor(p.rand(3))
#for trace in self:
#e = Ellipse((trace.x[0][j],trace.y[0][j]), width=trace.d1[0], height=trace.d2[0], angle=trace.theta[0])
#ax.add_artist(e)
#e.set_clip_box(ax.bbox)
#e.set_alpha(1)
#e.set_facecolor('r')
#e.set_edgecolor('r')
p.savefig(figname)
示例2: __init__
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_facecolor [as 别名]
def __init__(self, xy, closed=True, plotview=None, **opts):
shape = Polygon(xy, closed, **opts)
if 'linewidth' not in opts:
shape.set_linewidth(1.0)
if 'facecolor' not in opts:
shape.set_facecolor('r')
super(NXpolygon, self).__init__(shape, resize=False, plotview=plotview)
self.shape.set_label('Polygon')
self.polygon = self.shape
示例3: overlapping_bricks
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_facecolor [as 别名]
def overlapping_bricks(self, candidates, map_petals=False):
"""Convert a list of potentially overlapping bricks into actual overlaps.
Parameters
----------
candidates : :class:`list`
A list of candidate bricks.
map_petals : bool, optional
If ``True`` a map of petal number to a list of overlapping bricks
is returned.
Returns
-------
:class:`list`
A list of Polygon objects.
"""
petals = self.petals()
petal2brick = dict()
bricks = list()
for b in candidates:
b_ra1, b_ra2 = self.brick_offset(b)
brick_corners = np.array([[b_ra1, b.dec1],
[b_ra2, b.dec1],
[b_ra2, b.dec2],
[b_ra1, b.dec2]])
brick = Polygon(brick_corners, closed=True, facecolor='r')
for i, p in enumerate(petals):
if brick.get_path().intersects_path(p.get_path()):
brick.set_facecolor('g')
if i in petal2brick:
petal2brick[i].append(b.id)
else:
petal2brick[i] = [b.id]
bricks.append(brick)
if map_petals:
return petal2brick
return bricks
示例4: plot_fits_map
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_facecolor [as 别名]
#.........这里部分代码省略.........
# Set the format of the major tick mark and labels
if w['coord_type']=='EQU':
f = 15.0
majorFormatterX = FuncFormatter(label_format_hms)
minorFormatterX = None
majorFormatterY = FuncFormatter(label_format_dms)
minorFormattery = None
else:
f = 1.0
majorFormatterX = FuncFormatter(label_format_deg)
minorFormatterX = None
majorFormatterY = FuncFormatter(label_format_deg)
minorFormattery = None
ax.xaxis.set_major_formatter(majorFormatterX)
ax.yaxis.set_major_formatter(majorFormatterY)
# Set the location of the the major tick marks
#xrangeArcmin = abs(w['xmax']-w['xmin'])*(60.0*f)
#xmultiple = m.ceil(xrangeArcmin/3.0)/(60.0*f)
#yrangeArcmin = abs(w['ymax']-w['ymin'])*60.0
#ymultiple = m.ceil(yrangeArcmin/3.0)/60.0
#majorLocatorX = MultipleLocator(xmultiple)
#ax.xaxis.set_major_locator(majorLocatorX)
#majorLocatorY = MultipleLocator(ymultiple)
#ax.yaxis.set_major_locator(majorLocatorY)
ax.xaxis.set_major_locator(MaxNLocator(5))
ax.yaxis.set_major_locator(MaxNLocator(5))
# Print the image to the axis
im = ax.imshow(data, interpolation=interpolation, origin='lower',
aspect=aspect,
extent=[w['xmax'], w['xmin'], w['ymin'], w['ymax']],
cmap=plt.get_cmap(cmapName), norm=normalizer)
# Add the colorbar
if doColbar:
cbar = fig.colorbar(im, pad=0.0)
if 'BUNIT' in header:
cbar.set_label(header['BUNIT'])
else:
cbar.set_label('Unknown')
if not bunit is None:
cbar.set_label(bunit)
# Format the colourbar labels - TODO
# Set white ticks
ax.tick_params(pad=5)
for line in ax.xaxis.get_ticklines() + ax.get_yticklines():
line.set_markeredgewidth(1)
line.set_color('w')
# Create the ellipse source annotations
if len(annEllipseLst) > 0:
if len(annEllipseLst) >= 5:
srcXLst = np.array(annEllipseLst[0])
srcYLst = np.array(annEllipseLst[1])
srcMinLst = np.array(annEllipseLst[2])
srcMajLst = np.array(annEllipseLst[3])
srcPALst = np.array(annEllipseLst[4])
if len(annEllipseLst) >= 6:
if type(annEllipseLst[5]) is str:
srcEColLst = [annEllipseLst[5]] * len(srcXLst)
elif type(annEllipseLst[5]) is list:
srcEColLst = annEllipseLst[5]
else:
rcEColLst = ['g'] * len(srcXLst)
else:
srcEColLst = ['g'] * len(srcXLst)
for i in range(len(srcXLst)):
try:
el = Ellipse((srcXLst[i], srcYLst[i]), srcMinLst[i],
srcMajLst[i], angle=180.0-srcPALst[i],
edgecolor=srcEColLst[i],
linewidth=lw, facecolor='none')
ax.add_artist(el)
except Exception:
pass
# Create the polygon source annotations
if len(annPolyLst) > 0:
annPolyCoordLst = annPolyLst[0]
if len(annPolyLst) > 1:
if type(annPolyLst[1]) is str:
annPolyColorLst = [annPolyLst[1]] * len(annPolyCoordLst)
elif type(annPolyLst[1]) is list:
annPolyColorLst = annPolyLst[1]
else:
annPolyColorLst = ['g'] * len(annPolyCoordLst)
else:
annPolyColorLst = ['g'] * len(annPolyCoordLst)
for i in range(len(annPolyCoordLst)):
cpoly = Polygon(annPolyCoordLst[i], animated=False, linewidth=lw)
cpoly.set_edgecolor(annPolyColorLst[i])
cpoly.set_facecolor('none')
ax.add_patch(cpoly)
return fig
示例5: plotfits1
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_facecolor [as 别名]
#.........这里部分代码省略.........
fig = plt.figure(figsize=(9.5,8))
ax = fig.add_subplot(111, position=[0.1,0.08,0.9,0.87]) # Single pane
if w['coord_type']=='EQU':
ax.set_xlabel('RA (J2000)')
ax.set_ylabel('Dec (J2000)')
elif w['coord_type']=='GAL':
ax.set_xlabel('Galactic Longitude (Deg)')
ax.set_ylabel('Galactic Latitude (Deg)')
else:
ax.set_xlabel('Unknown')
ax.set_ylabel('Unknown')
cosy = m.cos(m.radians(w['ycent']))
aspect = abs(w['ydelt']/(w['xdelt']*cosy))
# Set the format of the tick mark labels
if w['coord_type']=='EQU':
f = 15.0
majorFormatterX = FuncFormatter(label_format_hms)
minorFormatterX = None
majorFormatterY = FuncFormatter(label_format_dms)
minorFormattery = None
else:
f = 1.0
majorFormatterX = FuncFormatter(label_format_deg)
minorFormatterX = None
majorFormatterY = FuncFormatter(label_format_deg)
minorFormattery = None
ax.xaxis.set_major_formatter(majorFormatterX)
ax.yaxis.set_major_formatter(majorFormatterY)
xrangeArcmin = abs(w['xmax']-w['xmin'])*(60.0*f)
xmultiple = m.ceil(xrangeArcmin/4.0)/(60.0*f)
yrangeArcmin = abs(w['ymax']-w['ymin'])*60.0
ymultiple = m.ceil(yrangeArcmin/4.0)/60.0
majorLocatorX = MultipleLocator(xmultiple)
ax.xaxis.set_major_locator(majorLocatorX)
majorLocatorY = MultipleLocator(ymultiple)
ax.yaxis.set_major_locator(majorLocatorY)
# Print the image to the figure
im = ax.imshow(data,interpolation=interpolation,origin='lower',
aspect=aspect,
extent=[w['xmax'],w['xmin'],w['ymin'],w['ymax']],
cmap=plt.get_cmap(cmapName),norm=normalizer)
# Add the colorbar
cbar = fig.colorbar(im ,pad=0.0)
cbar.set_label('mJy/beam')
# Set white ticks
for line in ax.xaxis.get_ticklines():
line.set_color('w')
for line in ax.yaxis.get_ticklines():
line.set_color('w')
# Create the ellipse source annotations
if len(annEllipseLst) > 0:
if len(annEllipseLst) >= 5:
srcRALst = np.array(annEllipseLst[0])
srcDecLst = np.array(annEllipseLst[1])
srcMinLst = np.array(annEllipseLst[2])
srcMajLst = np.array(annEllipseLst[3])
srcPALst = np.array(annEllipseLst[4])
if len(annEllipseLst) >= 6:
if type(annEllipseLst[5]) is str:
srcEColLst = [annEllipseLst[5]] * len(srcRALst)
elif type(annEllipseLst[5]) is list:
srcEColLst = annEllipseLst[5]
else:
rcEColLst = ['g'] * len(srcRALst)
else:
srcEColLst = ['g'] * len(srcRALst)
for i in range(len(srcRALst)):
el = Ellipse((srcRALst[i],srcDecLst[i]), srcMinLst[i],
srcMajLst[i], angle=180-srcPALst[i],
edgecolor=srcEColLst[i],
linewidth=lw, facecolor='none')
ax.add_artist(el)
# Create the polygon source annotations
if len(annPolyLst) > 0:
if type(annPolyColor) is str:
annPolyColor = [annPolyColor] * len(annPolyLst)
elif type(annPolyColor) is list:
pass
else:
annPolyColor =['g'] * len(annPolyLst)
for i in range(len(annPolyLst)):
cpoly = Polygon(annPolyLst[i], animated=False,linewidth=lw)
cpoly.set_edgecolor(annPolyColor[i])
cpoly.set_facecolor('none')
ax.add_patch(cpoly)
# Save to an image file (full-size & thumbnail images)
fig.savefig(outFile, dpi=dpi)
plt.close()
示例6: open
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_facecolor [as 别名]
# infile = open(curdir +'state_info_revised.csv','r')
# csvfile = csv.reader(infile)
# for line in csvfile:
# lon = (float(line[0]) + float(line[2]))/2 + float(line[5])
# lat = (float(line[1]) + float(line[3]))/2 + float(line[6])
# x, y = m(lon, lat)
# name = line[4].replace('\\n', '\n')
# plt.text(x, y, name, horizontalalignment='center', verticalalignment='center', fontsize=int(line[7]))
for lakepoly in m.lakepolygons:
lp = Polygon(lakepoly.boundary, zorder=2)
lp.set_facecolor('0.8')
lp.set_edgecolor('0.8')
lp.set_linewidth(0.1)
ax.add_patch(lp)
# xx, yy = m(-72.0, 26.0)
# plt.text(xx, yy, u'Made by zhyuey', color='yellow')
# plt.title('Map of contiguous United States', fontsize=24)
# # plt.savefig('usa_state_75.png', dpi=75)
# # plt.savefig('usa_state_75.png', dpi=75)
# plt.savefig('usa_state_300.png', dpi=300)
# # plt.savefig('usa_state_600.png', dpi=600)
示例7: LineCollection
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_facecolor [as 别名]
lines = LineCollection(segs,antialiaseds=(1,))
lines.set_facecolors(np.random.rand(3, 1) * 0.5 + 0.5)
lines.set_edgecolors('k')
lines.set_linewidth(0.1)
ax.add_collection(lines)
cnt += 1
infile = open(curdir +'state_info_revised.csv','r')
csvfile = csv.reader(infile)
for lakepoly in m.lakepolygons:
lp = Polygon(lakepoly.boundary, zorder=3)
lp.set_facecolor(thisblue)
lp.set_linewidth(0.1)
ax.add_patch(lp)
for line in csvfile:
lon = (float(line[0]) + float(line[2]))/2 + float(line[5])
lat = (float(line[1]) + float(line[3]))/2 + float(line[6])
x, y = m(lon, lat)
name = line[4].replace('\\n', '\n')
plt.text(x, y, name, horizontalalignment='center', verticalalignment='center', fontsize=int(line[7]))
xx, yy = m(-72.0, 26.0)
plt.text(xx, yy, u'Made by zhyuey', color='yellow')
plt.title('Map of contiguous United States', fontsize=24)
示例8: range
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_facecolor [as 别名]
segs = []
for i in range(1,len(shape.parts)):
index = shape.parts[i-1]
index2 = shape.parts[i]
segs.append(data[index:index2])
segs.append(data[index2:])
lines = LineCollection(segs,antialiaseds=(1,))
lines.set_facecolors(np.random.rand(3, 1) * 0.5 + 0.5)
lines.set_edgecolors('k')
lines.set_linewidth(0.1)
ax.add_collection(lines)
for lakepoly in m.lakepolygons:
lp = Polygon(lakepoly.boundary)
lp.set_facecolor('#0000aa')
ax.add_patch(lp)
# m.drawrivers(linewidth=0.5, zorder = 3, color='blue')
lon = (float(line[0]) + float(line[2]))/2 + float(line[5])
lat = (float(line[1]) + float(line[3]))/2 + float(line[6])
x, y = m(lon, lat)
name = line[4].replace('\\n', '\n')
plt.text(x, y, name, horizontalalignment='center', verticalalignment='center', fontsize=24)
filename = sys.path[0] + '/state_img/m_' + line[4] + '.png'
print(filename)