本文整理汇总了Python中matplotlib.patches.FancyArrowPatch类的典型用法代码示例。如果您正苦于以下问题:Python FancyArrowPatch类的具体用法?Python FancyArrowPatch怎么用?Python FancyArrowPatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FancyArrowPatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: draw
def draw(self, renderer):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
xs3d, ys3d, zs3d = self._verts3d
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
FancyArrowPatch.draw(self, renderer)
开发者ID:askerry,项目名称:FGE_MISC,代码行数:7,代码来源:vizfuncs.py
示例2: draw
def draw(self, renderer):
#xs3d, ys3d, zs3d = self._verts3d
for coords in self._verts3d:
xs3d, ys3d, zs3d = coords[0], coords[1], coords[2]
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
FancyArrowPatch.draw(self, renderer)
开发者ID:wgurecky,项目名称:spyTran,代码行数:7,代码来源:ordplot.py
示例3: _render_on_subplot
def _render_on_subplot(self, subplot):
"""
Render this arrow in a subplot. This is the key function that
defines how this arrow graphics primitive is rendered in
matplotlib's library.
EXAMPLES::
This function implicitly ends up rendering this arrow on a matplotlib subplot:
sage: arrow(path=[[(0,1), (2,-1), (4,5)]])
"""
options = self.options()
width = float(options['width'])
head = options.pop('head')
if head == 0: style = '<|-'
elif head == 1: style = '-|>'
elif head == 2: style = '<|-|>'
else: raise KeyError('head parameter must be one of 0 (start), 1 (end) or 2 (both).')
arrowsize = float(options.get('arrowsize',5))
head_width=arrowsize
head_length=arrowsize*2.0
color = to_mpl_color(options['rgbcolor'])
from matplotlib.patches import FancyArrowPatch
from matplotlib.path import Path
bpath = Path(self.vertices, self.codes)
p = FancyArrowPatch(path=bpath,
lw=width, arrowstyle='%s,head_width=%s,head_length=%s'%(style,head_width, head_length),
fc=color, ec=color, linestyle=options['linestyle'])
p.set_zorder(options['zorder'])
p.set_label(options['legend_label'])
subplot.add_patch(p)
return p
开发者ID:pombredanne,项目名称:sage-1,代码行数:32,代码来源:arrow.py
示例4: __init__
def __init__(self, ax, transSky2Pix, loc,
arrow_fraction=0.15,
txt1="E", txt2="N",
delta_a1=0, delta_a2=0,
pad=0.1, borderpad=0.5, prop=None, frameon=False,
):
"""
Draw an arrows pointing the directions of E & N
arrow_fraction : length of the arrow as a fraction of axes size
pad, borderpad in fraction of the legend font size (or prop)
"""
self._ax = ax
self._transSky2Pix = transSky2Pix
self._box = AuxTransformBox(ax.transData)
self.delta_a1, self.delta_a2 = delta_a1, delta_a2
self.arrow_fraction = arrow_fraction
kwargs = dict(mutation_scale=11,
shrinkA=0,
shrinkB=5)
self.arrow1 = FancyArrowPatch(posA=(0, 0), posB=(1, 1),
arrowstyle="->",
arrow_transmuter=None,
connectionstyle="arc3",
connector=None,
**kwargs)
self.arrow2 = FancyArrowPatch(posA=(0, 0), posB=(1, 1),
arrowstyle="->",
arrow_transmuter=None,
connectionstyle="arc3",
connector=None,
**kwargs)
x1t, y1t, x2t, y2t = 1, 1, 1, 1
self.txt1 = Text(x1t, y1t, txt1, rotation=0,
rotation_mode="anchor",
va="center", ha="right")
self.txt2 = Text(x2t, y2t, txt2, rotation=0,
rotation_mode="anchor",
va="bottom", ha="center")
self._box.add_artist(self.arrow1)
self._box.add_artist(self.arrow2)
self._box.add_artist(self.txt1)
self._box.add_artist(self.txt2)
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
child=self._box,
prop=prop,
frameon=frameon)
开发者ID:dreadtoad,项目名称:pywcsgrid2,代码行数:57,代码来源:aux_artists.py
示例5: draw
def draw(self, renderer):
"""
:param renderer:
"""
xs3d, ys3d, zs3d = self._verts3d
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
FancyArrowPatch.draw(self, renderer)
开发者ID:andrewbolster,项目名称:aietes,代码行数:9,代码来源:__init__.py
示例6: __init__
def __init__(self,xs,ys,zs,*args,**kwargs):
'''
arguments:
xs: the x coordinates of both sides of the arrow
ys: the y coordinates of both sides of the arrow
zs: the z coordinates of both sides of the arrow
'''
FancyArrowPatch.__init__(self,(0,0),(0,0),*args,**kwargs)
self.verts = xs,ys,zs
开发者ID:samhaug,项目名称:tplot,代码行数:13,代码来源:axes3d.py
示例7: draw
def draw(self, renderer, rasterized=True):
"""
Drawing actually happens here
"""
# Draws only when the dragging finished
if self.leftdown:
return
xs3d, ys3d, zs3d = self._verts3d
for i in xrange(len(xs3d)):
xs, ys, _ = proj3d.proj_transform(xs3d[i], ys3d[i], zs3d[i], renderer.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
self.set_color(self.colors[i])
FancyArrowPatch.draw(self, renderer)
self.leftdown = False
开发者ID:diffpy,项目名称:srfit-sasview,代码行数:15,代码来源:arrow3d.py
示例8: create_photon_legend
def create_photon_legend(self, legend, orig_handle,
xdescent, ydescent, width, height, fontsize,
trans):
xdata, ydata = get_photon_data2D(width, 0.8*height, 3, 100)
ydata += height*0.3
legline = Line2D(xdata, ydata)
self.update_prop(legline, orig_handle, legend)
legline.set_drawstyle('default')
legline.set_marker("")
legline.set_transform(trans)
yar = FancyArrowPatch((xdata[3],ydata[0]), (xdata[3]+0.3*width, ydata[0]),
mutation_scale=10,
lw=1, arrowstyle="-|>", color='y')
yar.set_transform(trans)
return [legline, yar]
开发者ID:apodemus,项目名称:thesis,代码行数:19,代码来源:CCD.arch.py
示例9: __init__
def __init__(self, base, xs, ys, zs, colors, *args, **kwargs):
"""
Init
:Params xs: [[x0, x0+dx0], [x1, x1+dx1], ...]
:Params ys: [[y0, y0+dy0], [y1, y1+dy1], ...]
:Params zs: [[z0, z0+dz0], [z1, z1+dz1], ...]
:Params colors: [[R0, G0, B0], [R1, G1, B1], ...]
where R, G, B ranges (0,1)
"""
FancyArrowPatch.__init__(self, (0, 0), (0, 0), *args, **kwargs)
self.leftdown = False
self.t_click = 0
self._verts3d = xs, ys, zs
self.colors = colors
self.base = base
if base != None:
# To turn the updating off during dragging
base.canvas.mpl_connect('button_press_event', self.on_left_down)
base.canvas.mpl_connect('button_release_event', self.on_left_up)
开发者ID:diffpy,项目名称:srfit-sasview,代码行数:21,代码来源:arrow3d.py
示例10: _render_on_subplot
def _render_on_subplot(self, subplot):
"""
Render this arrow in a subplot. This is the key function that
defines how this arrow graphics primitive is rendered in
matplotlib's library.
EXAMPLES::
This function implicitly ends up rendering this arrow on a matplotlib subplot:
sage: arrow(path=[[(0,1), (2,-1), (4,5)]])
Graphics object consisting of 1 graphics primitive
"""
from sage.plot.misc import get_matplotlib_linestyle
options = self.options()
width = float(options["width"])
head = options.pop("head")
if head == 0:
style = "<|-"
elif head == 1:
style = "-|>"
elif head == 2:
style = "<|-|>"
else:
raise KeyError("head parameter must be one of 0 (start), 1 (end) or 2 (both).")
arrowsize = float(options.get("arrowsize", 5))
head_width = arrowsize
head_length = arrowsize * 2.0
color = to_mpl_color(options["rgbcolor"])
from matplotlib.patches import FancyArrowPatch
from matplotlib.path import Path
bpath = Path(self.vertices, self.codes)
p = FancyArrowPatch(
path=bpath,
lw=width,
arrowstyle="%s,head_width=%s,head_length=%s" % (style, head_width, head_length),
fc=color,
ec=color,
)
p.set_linestyle(get_matplotlib_linestyle(options["linestyle"], return_type="long"))
p.set_zorder(options["zorder"])
p.set_label(options["legend_label"])
subplot.add_patch(p)
return p
开发者ID:sharmaeklavya2,项目名称:sage,代码行数:45,代码来源:arrow.py
示例11: __init__
def __init__(self, xs, ys, zs, *args, **kwargs):
FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
self._verts3d = xs, ys, zs
开发者ID:mrJelmert,项目名称:master-thesis,代码行数:3,代码来源:kubes.py
示例12: AnnotationBbox
class AnnotationBbox(martist.Artist, _AnnotationBase):
"""
Annotation-like class, but with offsetbox instead of Text.
"""
zorder = 3
def __str__(self):
return "AnnotationBbox(%g,%g)"%(self.xy[0],self.xy[1])
@docstring.dedent_interpd
def __init__(self, offsetbox, xy,
xybox=None,
xycoords='data',
boxcoords=None,
frameon=True, pad=0.4, # BboxPatch
annotation_clip=None,
box_alignment=(0.5, 0.5),
bboxprops=None,
arrowprops=None,
fontsize=None,
**kwargs):
"""
*offsetbox* : OffsetBox instance
*xycoords* : same as Annotation but can be a tuple of two
strings which are interpreted as x and y coordinates.
*boxcoords* : similar to textcoords as Annotation but can be a
tuple of two strings which are interpreted as x and y
coordinates.
*box_alignment* : a tuple of two floats for a vertical and
horizontal alignment of the offset box w.r.t. the *boxcoords*.
The lower-left corner is (0.0) and upper-right corner is (1.1).
other parameters are identical to that of Annotation.
"""
self.offsetbox = offsetbox
self.arrowprops = arrowprops
self.set_fontsize(fontsize)
if arrowprops is not None:
self._arrow_relpos = self.arrowprops.pop("relpos", (0.5, 0.5))
self.arrow_patch = FancyArrowPatch((0, 0), (1,1),
**self.arrowprops)
else:
self._arrow_relpos = None
self.arrow_patch = None
_AnnotationBase.__init__(self,
xy, xytext=xybox,
xycoords=xycoords, textcoords=boxcoords,
annotation_clip=annotation_clip)
martist.Artist.__init__(self, **kwargs)
#self._fw, self._fh = 0., 0. # for alignment
self._box_alignment = box_alignment
# frame
self.patch = FancyBboxPatch(
xy=(0.0, 0.0), width=1., height=1.,
facecolor='w', edgecolor='k',
mutation_scale=self.prop.get_size_in_points(),
snap=True
)
self.patch.set_boxstyle("square",pad=pad)
if bboxprops:
self.patch.set(**bboxprops)
self._drawFrame = frameon
def contains(self,event):
t,tinfo = self.offsetbox.contains(event)
#if self.arrow_patch is not None:
# a,ainfo=self.arrow_patch.contains(event)
# t = t or a
# self.arrow_patch is currently not checked as this can be a line - JJ
return t,tinfo
def get_children(self):
children = [self.offsetbox, self.patch]
if self.arrow_patch:
children.append(self.arrow_patch)
return children
def set_figure(self, fig):
if self.arrow_patch is not None:
self.arrow_patch.set_figure(fig)
self.offsetbox.set_figure(fig)
martist.Artist.set_figure(self, fig)
def set_fontsize(self, s=None):
#.........这里部分代码省略.........
开发者ID:AlexSzatmary,项目名称:matplotlib,代码行数:101,代码来源:offsetbox.py
示例13: __init__
def __init__(self, pt1, pt2, *args, **kwargs):
FancyArrowPatch.__init__(self, (0, 0), (0, 0), *args, **kwargs)
x = [pt1[0, 0], pt2[0, 0]]
y = [pt1[1, 0], pt2[1, 0]]
z = [pt1[2, 0], pt2[2, 0]]
self._verts3d = x, y, z
开发者ID:sakharin,项目名称:Plot,代码行数:6,代码来源:PlotMatPlotLib.py
示例14: AnchoredCompass
class AnchoredCompass(AnchoredOffsetbox):
def __init__(self, ax, transSky2Pix, loc,
arrow_fraction=0.15,
txt1="E", txt2="N",
delta_a1=0, delta_a2=0,
pad=0.1, borderpad=0.5, prop=None, frameon=False,
):
"""
Draw an arrows pointing the directions of E & N
arrow_fraction : length of the arrow as a fraction of axes size
pad, borderpad in fraction of the legend font size (or prop)
"""
self._ax = ax
self._transSky2Pix = transSky2Pix
self._box = AuxTransformBox(ax.transData)
self.delta_a1, self.delta_a2 = delta_a1, delta_a2
self.arrow_fraction = arrow_fraction
kwargs = dict(mutation_scale=11,
shrinkA=0,
shrinkB=5)
self.arrow1 = FancyArrowPatch(posA=(0, 0), posB=(1, 1),
arrowstyle="->",
arrow_transmuter=None,
connectionstyle="arc3",
connector=None,
**kwargs)
self.arrow2 = FancyArrowPatch(posA=(0, 0), posB=(1, 1),
arrowstyle="->",
arrow_transmuter=None,
connectionstyle="arc3",
connector=None,
**kwargs)
x1t, y1t, x2t, y2t = 1, 1, 1, 1
self.txt1 = Text(x1t, y1t, txt1, rotation=0,
rotation_mode="anchor",
va="center", ha="right")
self.txt2 = Text(x2t, y2t, txt2, rotation=0,
rotation_mode="anchor",
va="bottom", ha="center")
self._box.add_artist(self.arrow1)
self._box.add_artist(self.arrow2)
self._box.add_artist(self.txt1)
self._box.add_artist(self.txt2)
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
child=self._box,
prop=prop,
frameon=frameon)
def set_path_effects(self, path_effects):
for a in [self.arrow1, self.arrow2, self.txt1, self.txt2]:
a.set_path_effects(path_effects)
def _update_arrow(self, renderer):
ax = self._ax
x0, y0 = ax.viewLim.x0, ax.viewLim.y0
a1, a2 = estimate_angle(self._transSky2Pix, x0, y0)
a1, a2 = a1+self.delta_a1, a2+self.delta_a2
D = min(ax.viewLim.width, ax.viewLim.height)
d = D * self.arrow_fraction
x1, y1 = x0+d*np.cos(a1/180.*np.pi), y0+d*np.sin(a1/180.*np.pi)
x2, y2 = x0+d*np.cos(a2/180.*np.pi), y0+d*np.sin(a2/180.*np.pi)
self.arrow1.set_positions((x0, y0), (x1, y1))
self.arrow2.set_positions((x0, y0), (x2, y2))
d2 = d
x1t, y1t = x0+d2*np.cos(a1/180.*np.pi), y0+d2*np.sin(a1/180.*np.pi)
x2t, y2t = x0+d2*np.cos(a2/180.*np.pi), y0+d2*np.sin(a2/180.*np.pi)
self.txt1.set_position((x1t, y1t))
self.txt1.set_rotation(a1-180)
self.txt2.set_position((x2t, y2t))
self.txt2.set_rotation(a2-90)
def draw(self, renderer):
self._update_arrow(renderer)
super(AnchoredCompass, self).draw(renderer)
开发者ID:dreadtoad,项目名称:pywcsgrid2,代码行数:91,代码来源:aux_artists.py
示例15: _render_on_subplot
def _render_on_subplot(self, subplot):
r"""
Render this arrow in a subplot. This is the key function that
defines how this arrow graphics primitive is rendered in
matplotlib's library.
EXAMPLES:
This function implicitly ends up rendering this arrow on
a matplotlib subplot::
sage: arrow((0,1), (2,-1))
TESTS:
The length of the ends (shrinkA and shrinkB) should not depend
on the width of the arrow, because Matplotlib already takes
this into account. See :trac:`12836`::
sage: fig = Graphics().matplotlib()
sage: sp = fig.add_subplot(1,1,1)
sage: a = arrow((0,0), (1,1))
sage: b = arrow((0,0), (1,1), width=20)
sage: p1 = a[0]._render_on_subplot(sp)
sage: p2 = b[0]._render_on_subplot(sp)
sage: p1.shrinkA == p2.shrinkA
True
sage: p1.shrinkB == p2.shrinkB
True
Dashed arrows should have solid arrowheads,
:trac:`12852`. This test saves the plot of a dashed arrow to
an EPS file. Within the EPS file, ``stroke`` will be called
twice: once to draw the line, and again to draw the
arrowhead. We check that both calls do not occur while the
dashed line style is enabled::
sage: a = arrow((0,0), (1,1), linestyle='dashed')
sage: filename = tmp_filename(ext='.eps')
sage: a.save(filename=filename)
sage: with open(filename, 'r') as f:
....: contents = f.read().replace('\n', ' ')
sage: two_stroke_pattern = r'setdash.*stroke.*stroke.*setdash'
sage: import re
sage: two_stroke_re = re.compile(two_stroke_pattern)
sage: two_stroke_re.search(contents) is None
True
"""
options = self.options()
head = options.pop('head')
if head == 0: style = '<|-'
elif head == 1: style = '-|>'
elif head == 2: style = '<|-|>'
else: raise KeyError('head parameter must be one of 0 (start), 1 (end) or 2 (both).')
width = float(options['width'])
arrowshorten_end = float(options.get('arrowshorten',0))/2.0
arrowsize = float(options.get('arrowsize',5))
head_width=arrowsize
head_length=arrowsize*2.0
color = to_mpl_color(options['rgbcolor'])
from matplotlib.patches import FancyArrowPatch
p = FancyArrowPatch((self.xtail, self.ytail), (self.xhead, self.yhead),
lw=width, arrowstyle='%s,head_width=%s,head_length=%s'%(style,head_width, head_length),
shrinkA=arrowshorten_end, shrinkB=arrowshorten_end,
fc=color, ec=color, linestyle=options['linestyle'])
p.set_zorder(options['zorder'])
p.set_label(options['legend_label'])
if options['linestyle']!='solid':
# The next few lines work around a design issue in matplotlib. Currently, the specified
# linestyle is used to draw both the path and the arrowhead. If linestyle is 'dashed', this
# looks really odd. This code is from Jae-Joon Lee in response to a post to the matplotlib mailing
# list. See http://sourceforge.net/mailarchive/forum.php?thread_name=CAG%3DuJ%2Bnw2dE05P9TOXTz_zp-mGP3cY801vMH7yt6vgP9_WzU8w%40mail.gmail.com&forum_name=matplotlib-users
import matplotlib.patheffects as pe
class CheckNthSubPath(object):
def __init__(self, patch, n):
"""
creates an callable object that returns True if the provided
path is the n-th path from the patch.
"""
self._patch = patch
self._n = n
def get_paths(self, renderer):
self._patch.set_dpi_cor(renderer.points_to_pixels(1.))
paths, fillables = self._patch.get_path_in_displaycoord()
return paths
def __call__(self, renderer, gc, tpath, affine, rgbFace):
path = self.get_paths(renderer)[self._n]
vert1, code1 = path.vertices, path.codes
import numpy as np
if np.all(vert1 == tpath.vertices) and np.all(code1 == tpath.codes):
return True
else:
return False
#.........这里部分代码省略.........
开发者ID:felix-salfelder,项目名称:sage,代码行数:101,代码来源:arrow.py
示例16: draw_network
def draw_network(G, pos, node_color=None, ax=None,
radius=1.4, node_alpha=0.5, edge_alpha=0.25,
fontsize=12, only_nodes = None):
"""Improved drawing of directed graphs in NetworkX.
Modified from http://groups.google.com/group/networkx-discuss/
browse_thread/thread/170624d22c4b0ee6?pli=1.
Author of original: Stefan van der Walt
Parameters
----------
pos : dictionary
A dictionary with nodes as keys and positions as values.
node_color : string or array of floats
A single color format string, or a sequence of colors with an entry
for each node in G.
"""
if ax is None:
f, ax = plt.subplots()
if only_nodes is None:
only_nodes = set(G.nodes())
only_nodes = set(only_nodes) if not isinstance(only_nodes, set) else \
only_nodes
# Find the set of all the nodes connected to the ones we want to highlight
connected = set()
for n in only_nodes:
connected.update(G.predecessors(n) + G.successors(n))
# Walk and draw nodes
for i, n in enumerate(G.nodes()):
if node_color is None:
color = (0, 0, 0)
else:
color = node_color[n]
#if node_color is None or cmap is None:
# color = (0,0,0)
#else:
# color = cmap(node_color[n])
# Selectively de-highlight nodes not being shown
if n in only_nodes:
t_alpha = 1.0
n_alpha = node_alpha
zorder = 2.2
elif n in connected:
t_alpha = n_alpha = 0.6*node_alpha
zorder = 2.0
else:
t_alpha = n_alpha = 0.15*node_alpha
zorder = 1.8
c = Circle(pos[n],radius=radius,
alpha=n_alpha,
color=color,ec='k')
x, y = pos[n]
t = plt.text(x, y, n, horizontalalignment='center',
verticalalignment='center', color='k', fontsize=fontsize,
weight='bold', alpha=t_alpha)
t.set_zorder(zorder+0.1)
c = ax.add_patch(c)
c.set_zorder(zorder)
G.node[n]['patch']=c
x,y=pos[n]
# Walk and draw edges. Keep track of edges already seen to offset
# multiedges and merge u<->v edges into one.
seen={}
for (u,v) in G.edges(data=False):
if not (u in only_nodes or v in only_nodes):
continue
n1 = G.node[u]['patch']
n2 = G.node[v]['patch']
rad=0.1
color = 'k'
if (u,v) in seen:
# For multiedges, offset new ones
rad=seen.get((u,v))
rad=(rad + np.sign(rad)*0.1)*-1
# If the opposite edge had already been drawn, draw on the same line to
# reduce clutter.
if (v,u) in seen:
arrowstyle = '<|-'
c1, c2, pA, pB = n2.center, n1.center, n2, n1
else:
arrowstyle = '-|>'
c1, c2, pA, pB = n1.center, n2.center, n1, n2
e = FancyArrowPatch(c1, c2, patchA=pA, patchB=pB,
arrowstyle=arrowstyle,
connectionstyle='arc3,rad=%s'%rad,
#.........这里部分代码省略.........
开发者ID:MSenden,项目名称:CoCoTools,代码行数:101,代码来源:nxdraw.py
示例17: draw
def draw(self,renderer):
xp,yp,zp = proj3d.proj_transform(*self.verts,M=renderer.M)
self.set_positions((xp[0],yp[0]),(xp[1],yp[1]))
FancyArrowPatch.draw(self,renderer)
开发者ID:samhaug,项目名称:tplot,代码行数:4,代码来源:axes3d.py
示例18: __init__
def __init__(self, xs, ys, zs, *args, **kwargs):
kwargs.update(dict(mutation_scale=20, lw=1, arrowstyle='-|>'))
FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
self._verts3d = xs, ys, zs
开发者ID:brianhou,项目名称:GPIS,代码行数:4,代码来源:graspable_object.py
示例19: __init__
def __init__(self, xs, ys, zs, *args, **kwargs):
"""Create arrow."""
FancyArrowPatch.__init__(self, (0, 0), (0, 0), *args, **kwargs)
self._verts3d = xs, ys, zs
开发者ID:LuisCarlosEiras,项目名称:qiskit-sdk-py,代码行数:4,代码来源:visualization.py
示例20: asteroids_plot
#.........这里部分代码省略.........
data = hdu.data.astype(float)
bkg = sep.Background(data)
# bkg_image = bkg.back()
# bkg_rms = bkg.rms()
data_sub = data - bkg
m, s = np.mean(data_sub), np.std(data_sub)
ax = plt.subplot(projection=wcs)
plt.imshow(data_sub, interpolation='nearest',
cmap='gray', vmin=m - s, vmax=m + s, origin='lower')
ax.coords.grid(True, color='white', ls='solid')
ax.coords[0].set_axislabel('Galactic Longitude')
ax.coords[1].set_axislabel('Galactic Latitude')
overlay = ax.get_coords_overlay('icrs')
overlay.grid(color='white', ls='dotted')
overlay[0].set_axislabel('Right Ascension (ICRS)')
overlay[1].set_axislabel('Declination (ICRS)')
sb = Query()
ac = AstCalc()
if image_path:
fo = FitsOps(image_path)
if not odate:
odate = fo.get_header('date-obs')
else:
odate = odate
ra_dec = ac.center_finder(image_path, wcs_ref=True)
elif not image_path and ra and dec and odate:
odate = odate
ra_dec = [co.ra, co.dec]
request0 = sb.find_skybot_objects(odate,
ra_dec[0].degree,
ra_dec[1].degree,
radius=radi)
if request0[0]:
asteroids = request0[1]
elif request0[0] is False:
print(request0[1])
raise SystemExit
request1 = sb.find_skybot_objects(odate,
ra_dec[0].degree,
ra_dec[1].degree,
radius=float(radi),
time_travel=time_travel)
if request1[0]:
asteroids_after = request1[1]
elif request1[0] is False:
print(request1[1])
raise SystemExit
for i in range(len(asteroids)):
if float(asteroids['m_v'][i]) <= max_mag:
c = coordinates.SkyCoord('{0} {1}'.format(
asteroids['ra(h)'][i],
asteroids['dec(deg)'][i]),
unit=(u.hourangle, u.deg),
frame='icrs')
c_after = coordinates.SkyCoord('{0} {1}'.format(
asteroids_after['ra(h)'][i],
asteroids_after['dec(deg)'][i]),
unit=(u.hourangle, u.deg),
frame='icrs')
r = FancyArrowPatch(
(c.ra.degree, c.dec.degree),
(c_after.ra.degree, c_after.dec.degree),
arrowstyle='->',
mutation_scale=10,
transform=ax.get_transform('icrs'))
p = Circle((c.ra.degree, c.dec.degree), 0.005,
edgecolor=circle_color,
facecolor='none',
transform=ax.get_transform('icrs'))
ax.text(c.ra.degree,
c.dec.degree - 0.007,
asteroids['name'][i],
size=12,
color='black',
ha='center',
va='center',
transform=ax.get_transform('icrs'))
r.set_facecolor('none')
r.set_edgecolor(arrow_color)
ax.add_patch(p)
ax.add_patch(r)
# plt.gca().invert_xaxis()
plt.gca().invert_yaxis()
plt.show()
print(asteroids)
return True
开发者ID:yucelkilic,项目名称:astrolib,代码行数:101,代码来源:visuals.py
注:本文中的matplotlib.patches.FancyArrowPatch类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论