本文整理汇总了Python中pylab.draw方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.draw方法的具体用法?Python pylab.draw怎么用?Python pylab.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylab
的用法示例。
在下文中一共展示了pylab.draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: complex_function
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def complex_function(f='1.0/(1+1j*x)', xmin=-1, xmax=1, steps=200, p='x', g=None, erange=False, **kwargs):
"""
Plots function(s) in the complex plane over the specified range.
Parameters
----------
f='1.0/(1+1j*x)'
Complex-valued function or list of functions to plot.
These can be string functions or single-argument python functions;
additional globals can be supplied by g.
xmin=-1, xmax=1, steps=200
Range over which to plot and how many points to plot
p='x'
If using strings for functions, p is the independent parameter name.
g=None
Optional dictionary of extra globals. Try g=globals()!
erange=False
Use exponential spacing of the x data?
See spinmob.plot.xy.data() for additional optional keyword arguments.
"""
kwargs2 = dict(xlabel='Real', ylabel='Imaginary')
kwargs2.update(kwargs)
function(f, xmin, xmax, steps, p, g, erange, plotter=xy_data, complex_plane=True, draw=True, **kwargs2)
示例2: image_coarsen
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def image_coarsen(xlevel=0, ylevel=0, image="auto", method='average'):
"""
This will coarsen the image data by binning each xlevel+1 along the x-axis
and each ylevel+1 points along the y-axis
type can be 'average', 'min', or 'max'
"""
if image == "auto": image = _pylab.gca().images[0]
Z = _n.array(image.get_array())
# store this image in the undo list
global image_undo_list
image_undo_list.append([image, Z])
if len(image_undo_list) > 10: image_undo_list.pop(0)
# images have transposed data
image.set_array(_fun.coarsen_matrix(Z, ylevel, xlevel, method))
# update the plot
_pylab.draw()
示例3: image_click_yshift
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def image_click_yshift(axes = "gca"):
"""
Takes a starting and ending point, then shifts the image y by this amount
"""
if axes == "gca": axes = _pylab.gca()
try:
p1 = _pylab.ginput()
p2 = _pylab.ginput()
yshift = p2[0][1]-p1[0][1]
e = axes.images[0].get_extent()
e[2] = e[2] + yshift
e[3] = e[3] + yshift
axes.images[0].set_extent(e)
_pylab.draw()
except:
print("whoops")
示例4: image_shift
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def image_shift(xshift=0, yshift=0, axes="gca"):
"""
This will shift an image to a new location on x and y.
"""
if axes=="gca": axes = _pylab.gca()
e = axes.images[0].get_extent()
e[0] = e[0] + xshift
e[1] = e[1] + xshift
e[2] = e[2] + yshift
e[3] = e[3] + yshift
axes.images[0].set_extent(e)
_pylab.draw()
示例5: image_set_clim
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def image_set_clim(zmin=None, zmax=None, axes="gca"):
"""
This will set the clim (range) of the colorbar.
Setting zmin or zmax to None will not change them.
Setting zmin or zmax to "auto" will auto-scale them to include all the data.
"""
if axes=="gca": axes=_pylab.gca()
image = axes.images[0]
if zmin=='auto': zmin = _n.min(image.get_array())
if zmax=='auto': zmax = _n.max(image.get_array())
if zmin==None: zmin = image.get_clim()[0]
if zmax==None: zmax = image.get_clim()[1]
image.set_clim(zmin, zmax)
_pylab.draw()
示例6: reverse_draw_order
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def reverse_draw_order(axes="current"):
"""
This function takes the graph and reverses the draw order.
"""
if axes=="current": axes = _pylab.gca()
# get the lines from the plot
lines = axes.get_lines()
# reverse the order
lines.reverse()
for n in range(0, len(lines)):
if isinstance(lines[n], _mpl.lines.Line2D):
axes.lines[n]=lines[n]
_pylab.draw()
示例7: set_all_line_attributes
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def set_all_line_attributes(attribute="lw", value=2, axes="current", refresh=True):
"""
This function sets all the specified line attributes.
"""
if axes=="current": axes = _pylab.gca()
# get the lines from the plot
lines = axes.get_lines()
# loop over the lines and trim the data
for line in lines:
if isinstance(line, _mpl.lines.Line2D):
_pylab.setp(line, attribute, value)
# update the plot
if refresh: _pylab.draw()
示例8: smooth_all_traces
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def smooth_all_traces(smoothing=1, trim=True, axes="gca"):
"""
This function does nearest-neighbor smoothing of the data
"""
if axes=="gca": axes=_pylab.gca()
# get the lines from the plot
lines = axes.get_lines()
# loop over the lines and trim the data
for line in lines:
if isinstance(line, _mpl.lines.Line2D):
smooth_line(line, smoothing, trim, draw=False)
_pylab.draw()
示例9: line_math
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def line_math(fx=None, fy=None, axes='gca'):
"""
applies function fx to all xdata and fy to all ydata.
"""
if axes=='gca': axes = _pylab.gca()
lines = axes.get_lines()
for line in lines:
if isinstance(line, _mpl.lines.Line2D):
xdata, ydata = line.get_data()
if not fx==None: xdata = fx(xdata)
if not fy==None: ydata = fy(ydata)
line.set_data(xdata,ydata)
_pylab.draw()
示例10: apply
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def apply(self, axes="gca"):
"""
Applies the style cycle to the lines in the axes specified
"""
if axes == "gca": axes = _pylab.gca()
self.reset()
lines = axes.get_lines()
for l in lines:
l.set_color(self.get_line_color(1))
l.set_mfc(self.get_face_color(1))
l.set_marker(self.get_marker(1))
l.set_mec(self.get_edge_color(1))
l.set_linestyle(self.get_linestyle(1))
_pylab.draw()
示例11: drawPrfast
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def drawPrfast(tp, fp, tot, show=True, col="g"):
tp = numpy.cumsum(tp)
fp = numpy.cumsum(fp)
rec = tp / tot
prec = tp / (fp + tp)
ap = VOColdap(rec, prec)
ap1 = VOCap(rec, prec)
if show:
pylab.plot(rec, prec, '-%s' % col)
pylab.title("AP=%.1f 11pt(%.1f)" % (ap1 * 100, ap * 100))
pylab.xlabel("Recall")
pylab.ylabel("Precision")
pylab.grid()
pylab.gca().set_xlim((0, 1))
pylab.gca().set_ylim((0, 1))
pylab.show()
pylab.draw()
return rec, prec, ap1
示例12: save_plot
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def save_plot(self, filename):
plt.ion()
targarr = np.array(self.targvalue)
self.posi[0].set_xdata(self.wt_positions[:,0])
self.posi[0].set_ydata(self.wt_positions[:,1])
while len(self.plotel)>0:
self.plotel.pop(0).remove()
self.plotel = self.shape_plot.plot(np.array([self.wt_positions[[i,j],0] for i, j in self.elnet_layout.keys()]).T,
np.array([self.wt_positions[[i,j],1] for i, j in self.elnet_layout.keys()]).T, 'y-', linewidth=1)
for i in range(len(self.posb)):
self.posb[i][0].set_xdata(self.iterations)
self.posb[i][0].set_ydata(targarr[:,i])
self.legend.texts[i].set_text('%s = %8.2f'%(self.targname[i], targarr[-1,i]))
self.objf_plot.set_xlim([0, self.iterations[-1]])
self.objf_plot.set_ylim([0.5, 1.2])
if not self.title == '':
plt.title('%s = %8.2f'%(self.title, getattr(self, self.title)))
plt.draw()
#print self.iterations[-1] , ': ' + ', '.join(['%s=%6.2f'%(self.targname[i], targarr[-1,i]) for i in range(len(self.targname))])
with open(self.result_file+'.results','a') as f:
f.write( '%d:'%(self.inc) + ', '.join(['%s=%6.2f'%(self.targname[i], targarr[-1,i]) for i in range(len(self.targname))]) +
'\n')
#plt.show()
#plt.savefig(filename)
display(plt.gcf())
#plt.show()
clear_output(wait=True)
示例13: update_image
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def update_image(self):
"""
Set's the image's cmap.
"""
if self._image:
self._image.set_cmap(self.get_cmap())
_pylab.draw()
示例14: complex_databoxes
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def complex_databoxes(ds, script='d[1]+1j*d[2]', escript=None, **kwargs):
"""
Uses databoxes and specified script to generate data and send to
spinmob.plot.complex_data()
Parameters
----------
ds
List of databoxes
script='d[1]+1j*d[2]'
Complex-valued script for data array.
escript=None
Complex-valued script for error bars
See spinmob.plot.complex.data() for additional optional keyword arguments.
See spinmob.data.databox.execute_script() for more information about scripts.
"""
datas = []
labels = []
if escript is None: errors = None
else: errors = []
for d in ds:
datas.append(d(script))
labels.append(_os.path.split(d.path)[-1])
if not escript is None: errors.append(d(escript))
complex_data(datas, errors, label=labels, **kwargs)
if "draw" in kwargs and not kwargs["draw"]: return
_pylab.ion()
_pylab.draw()
_pylab.show()
return ds
示例15: add_text
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import draw [as 别名]
def add_text(text, x=0.01, y=0.01, axes="gca", draw=True, **kwargs):
"""
Adds text to the axes at the specified position.
**kwargs go to the axes.text() function.
"""
if axes=="gca": axes = _pylab.gca()
axes.text(x, y, text, transform=axes.transAxes, **kwargs)
if draw: _pylab.draw()