本文整理汇总了Python中pylab.ion函数的典型用法代码示例。如果您正苦于以下问题:Python ion函数的具体用法?Python ion怎么用?Python ion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ion函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hinton
def hinton(W, maxWeight=None):
"""
Draws a Hinton diagram for visualizing a weight matrix.
Temporarily disables matplotlib interactive mode if it is on,
otherwise this takes forever.
"""
reenable = False
if P.isinteractive():
P.ioff()
P.clf()
height, width = W.shape
if not maxWeight:
maxWeight = 2**N.ceil(N.log(N.max(N.abs(W)))/N.log(2))
P.fill(N.array([0,width,width,0]),N.array([0,0,height,height]),'gray')
P.axis('off')
P.axis('equal')
for x in xrange(width):
for y in xrange(height):
_x = x+1
_y = y+1
w = W[y,x]
if w > 0:
_blob(_x - 0.5, height - _y + 0.5, min(1,w/maxWeight),'white')
elif w < 0:
_blob(_x - 0.5, height - _y + 0.5, min(1,-w/maxWeight),'black')
if reenable:
P.ion()
P.show()
示例2: test_path
def test_path():
"generate and draw a random path"
path = genpath()
P.ion()
P.clf()
draw_path(P.gca(), path)
P.draw()
示例3: cmap_plot
def cmap_plot(cmdLine):
pylab.figure(figsize=[5,10])
a=outer(ones(10),arange(0,1,0.01))
subplots_adjust(top=0.99,bottom=0.00,left=0.01,right=0.8)
maps=[m for m in cm.datad if not m.endswith("_r")]
maps.sort()
l=len(maps)+1
for i, m in enumerate(maps):
print m
subplot(l,1,i+1)
pylab.setp(pylab.gca(),xticklabels=[],xticks=[],yticklabels=[],yticks=[])
imshow(a,aspect='auto',cmap=get_cmap(m),origin="lower")
pylab.text(100.85,0.5,m,fontsize=10)
# render plot
if cmdLine:
pylab.show(block=True)
else:
pylab.ion()
pylab.plot([])
pylab.ioff()
status = 1
return status
示例4: __init__
def __init__(self, ca, cmap=None):
"""
CAPlotter() constructor keeps a reference to the CA model, and
optionally a colormap to be used with plots.
Parameters
----------
ca : LandlabCellularAutomaton object
Reference to a CA model
cmap : Matplotlib colormap (optional)
Colormap to be used in plotting
"""
import matplotlib
# Set the colormap; default to matplotlib's "jet" colormap
if cmap is None:
self._cmap = matplotlib.cm.jet
else:
self._cmap = cmap
# Keep a reference to the CA model
self.ca = ca
# Initialize the plot and remember the grid type
plt.ion()
plt.figure(1)
if type(ca.grid) is landlab.grid.hex.HexModelGrid:
self.gridtype = 'hex'
else:
self.gridtype = 'rast'
示例5: __init__
def __init__(self, window_size, easting_offset, northing_offset):
self.rad_to_deg = 180.0/pi
# Get parameters
self.plot_pose = plot_pose
self.plot_gnss = plot_gnss
self.plot_odometry = plot_odometry
self.plot_yaw = plot_yaw
self.trkpt_threshold = 0.1 # [m]
# Initialize map
self.offset_e = easting_offset
self.offset_n = northing_offset
self.window_size = window_size
self.map_title = map_title
self.odo = []
self.gnss = []
self.pose_pos = []
self.odo_yaw = []
self.gnss_yaw = []
self.ahrs_yaw = []
self.pose_yaw = []
self.wpt_mode = 0
self.wpt_destination = False
self.wpt_target = False
self.pose_image_save = True # save an image for time-lapse video generation
self.pose_image_count = 0
ion() # turn interaction mode on
示例6: qqplotp
def qqplotp(pv,fileout = None, pnames=pnames(), rownames=rownames(),alphalevel = 0.05,legend=None,xlim=None,ylim=None,ycoord=10,plotsize="652x526",title=None,dohist=True):
'''
Read in p-values from filein and make a qqplot adn histogram.
If fileout is provided, saves the qqplot only at present.
Searches through p until one is found. '''
import pylab as pl
pl.ion()
fs=8
h1=qqplot(pv, fileout, alphalevel,legend,xlim,ylim,addlambda=True)
#lambda_gc=estimate_lambda(pv)
#pl.legend(["gc="+ '%1.3f' % lambda_gc],loc=2)
pl.title(title,fontsize=fs)
#wm=pl.get_current_fig_manager()
#e.g. "652x526+100+10
xcoord=100
#wm.window.wm_geometry(plotsize + "+" + str(xcoord) + "+" + str(ycoord))
if dohist:
h2=pvalhist(pv)
pl.title(title,fontsize=fs)
#wm=pl.get_current_fig_manager()
width_height=plotsize.split("x")
buffer=10
xcoord=int(xcoord + float(width_height[0])+buffer)
#wm.window.wm_geometry(plotsize + "+" + str(xcoord) + "+" + str(ycoord))
else: h2=None
return h1,h2
示例7: drawModel
def drawModel(self):
PL.ion() # bug fix by Alex Hill in 2013
if self.modelFigure == None or self.modelFigure.canvas.manager.window == None:
self.modelFigure = PL.figure()
self.modelDrawFunc()
self.modelFigure.canvas.manager.window.update()
PL.show() # bug fix by Hiroki Sayama in 2016
示例8: run
def run(self):
plts = {}
graphs = {}
pos = 0
plt.ion()
plt.style.use('ggplot')
for name in sorted(self.names.values()):
p = plt.subplot(math.ceil(len(self.names) / 2), 2, pos+1)
p.set_ylim([0, 100])
p.set_title(self.machine_classes[name] + " " + name)
p.get_xaxis().set_visible(False)
X = range(0, NUM_ENTRIES, 1)
Y = NUM_ENTRIES * [0]
graphs[name] = p.plot(X, Y)[0]
plts[name] = p
pos += 1
plt.tight_layout()
while True:
for name, p in plts.items():
graphs[name].set_ydata(self.loads[name])
plt.draw()
plt.pause(0.05)
示例9: animate_1D
def animate_1D(time, var, x, ylab=' '):
"""Animate a 2d array with a sequence of 1d plots
Input: time = one-dimensional time vector;
var = array with first dimension = len(time) ;
x = (optional) vector width dimension equal to var.shape[1];
ylab = ylabel for plot
"""
import pylab
import numpy
pylab.close()
pylab.ion()
# Initial plot
vmin=var.min()
vmax=var.max()
line, = pylab.plot( (x.min(), x.max()), (vmin, vmax), 'o')
# Lots of plots
for i in range(len(time)):
line.set_xdata(x)
line.set_ydata(var[i,:])
pylab.draw()
pylab.xlabel('x')
pylab.ylabel(ylab)
pylab.title('time = ' + str(time[i]))
return
示例10: sintest
def sintest(self, AMP=0.5, FREQ=1, TIME=5, mode='velocity'):
# freq in hertz
# amp in radians
self.tstart = time.time()
t = time.time()-self.tstart
self.setpos(0)
pylab.ion()
print('**Running Sin Test**')
while t<TIME:
t = time.time()-self.tstart
ctrl = AMP*np.sin(FREQ*2.0*np.pi*t)
if mode == 'velocity':
self.setvel(ctrl)
output = self.getvel()
if mode == 'pos':
self.setpos(ctrl)
output = self.getpos()
pylab.plot([t],[output],color='blue', marker='*')
pylab.plot([t],[ctrl],color='red')
pylab.draw()
self.stop()
示例11: __init__
def __init__(self, net, task, valueNetwork=None, **args):
self.net = net
self.task = task
self.setArgs(**args)
if self.valueLearningRate == None:
self.valueLearningRate = self.learningRate
if self.valueMomentum == None:
self.valueMomentum = self.momentum
if self.supervisedPlotting:
from pylab import ion
ion()
# adaptive temperature:
self.tau = 1.
# prepare the datasets to be used
self.weightedDs = ImportanceDataSet(self.task.outdim, self.task.indim)
self.rawDs = ReinforcementDataSet(self.task.outdim, self.task.indim)
self.valueDs = SequentialDataSet(self.task.outdim, 1)
# prepare the supervised trainers
self.bp = BackpropTrainer(self.net, self.weightedDs, self.learningRate,
self.momentum, verbose=False,
batchlearning=True)
# CHECKME: outsource
self.vnet = valueNetwork
if valueNetwork != None:
self.vbp = BackpropTrainer(self.vnet, self.valueDs, self.valueLearningRate,
self.valueMomentum, verbose=self.verbose)
# keep information:
self.totalSteps = 0
self.totalEpisodes = 0
示例12: histoCase
def histoCase( self ):
print "Building Histogram"
header = self.histoAxis.get()
if ( self.filterNum.get() == "None" ):
data = self.dataInstance.getNumericAxis( self.histoAxis.get() )
else:
labels = []
data = []
for set in self.main.histoCols:
labels.append( set[0] )
data.append( set[1] )
pylab.ion()
if ( self.filterNum.get() == "None" ):
pylab.hist( data, bins=self.bins.get(), label=header )
else:
pylab.hist( data, bins=self.bins.get(), label=labels )
pylab.legend()
pylab.xlabel( header )
pylab.ylabel("Frequency")
pylab.title("Histogram" )
pylab.show()
示例13: plotInit
def plotInit(Plotting, Elements):
if (Plotting == 2):
loc = [i.xy for i in Elements]
x = [i.real for i in loc]
y = [i.imag for i in loc]
x = list(sorted(set(x)))
x.remove(-10)
y = list(sorted(set(y)))
X, Y = pylab.meshgrid(x, y)
U = pylab.ones(shape(X))
V = pylab.ones(shape(Y))
pylab.ion()
fig, ax = pylab.subplots(1,1)
graph = ax.quiver(X, Y, U, V)
pylab.draw()
else:
pylab.ion()
graph, = pylab.plot(1, 'ro', markersize = 2)
x = 2
pylab.axis([-x,x,x,-x])
graph.set_xdata(0)
graph.set_ydata(0)
pylab.draw()
return graph
示例14: __init__
def __init__(self,file):
# Task parameters
self.running = True
# Class variables
self.origin = Vector(0,0)
self.position = Vector(0,0)
self.position_list = []
# init plot
self.fig = pyplot.figure(num=None, figsize=(8, 8), dpi=80, facecolor='w', edgecolor='k')
self.area = 2
ion()
# Init transform
self.tf = tf.TransformListener()
self.br = tf.TransformBroadcaster()
self.quaternion = np.empty((4, ), dtype=np.float64)
# Init node
self.rate = rospy.Rate(10)
# Init subscriber
self.imu_sub = rospy.Subscriber('/fmInformation/imu', Imu, self.onImu )
# Init stat
self.file = file
self.deviations = []
示例15: plotDirections
def plotDirections(aabb=(),mask=0,bins=20,numHist=True,noShow=False,sphSph=False):
"""Plot 3 histograms for distribution of interaction directions, in yz,xz and xy planes and
(optional but default) histogram of number of interactions per body. If sphSph only sphere-sphere interactions are considered for the 3 directions histograms.
:returns: If *noShow* is ``False``, displays the figure and returns nothing. If *noShow*, the figure object is returned without being displayed (works the same way as :yref:`yade.plot.plot`).
"""
import pylab,math
from yade import utils
for axis in [0,1,2]:
d=utils.interactionAnglesHistogram(axis,mask=mask,bins=bins,aabb=aabb,sphSph=sphSph)
fc=[0,0,0]; fc[axis]=1.
subp=pylab.subplot(220+axis+1,polar=True);
# 1.1 makes small gaps between values (but the column is a bit decentered)
pylab.bar(d[0],d[1],width=math.pi/(1.1*bins),fc=fc,alpha=.7,label=['yz','xz','xy'][axis])
#pylab.title(['yz','xz','xy'][axis]+' plane')
pylab.text(.5,.25,['yz','xz','xy'][axis],horizontalalignment='center',verticalalignment='center',transform=subp.transAxes,fontsize='xx-large')
if numHist:
pylab.subplot(224,polar=False)
nums,counts=utils.bodyNumInteractionsHistogram(aabb if len(aabb)>0 else utils.aabbExtrema())
avg=sum([nums[i]*counts[i] for i in range(len(nums))])/(1.*sum(counts))
pylab.bar(nums,counts,fc=[1,1,0],alpha=.7,align='center')
pylab.xlabel('Interactions per body (avg. %g)'%avg)
pylab.axvline(x=avg,linewidth=3,color='r')
pylab.ylabel('Body count')
if noShow: return pylab.gcf()
else:
pylab.ion()
pylab.show()