本文整理汇总了Python中matplotlib.pylab.draw方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.draw方法的具体用法?Python pylab.draw怎么用?Python pylab.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pylab
的用法示例。
在下文中一共展示了pylab.draw方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _make_widgets
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import draw [as 别名]
def _make_widgets(self):
"""
Creates the sliders
:return:
"""
if hasattr(self, 'sliders'):
for s in self.sliders:
s.ax.remove()
sliders = []
step = max(0.005, min(0.05, 0.8/len(self.parameter_array)))
for i, row in enumerate(self.parameter_array):
rect = [0.75, 0.9 - step * i, 0.2, step - 0.005]
s = Widget(rect, Slider, row['name'], row['minbound'], row['maxbound'],
valinit=row['optguess'], on_changed=ValueChanger(row['name'], self.parameter_values))
sliders.append(s)
plt.draw()
return sliders
示例2: run
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import draw [as 别名]
def run(self, _=None):
"""
Runs the model and plots the result
"""
self.ax.set_title('Calculating...')
plt.draw()
time.sleep(0.001)
parset = create_set(self.setup, **self.parameter_values)
sim = self.setup.simulation(parset)
objf = as_scalar(self.setup.objectivefunction(sim, self.setup.evaluation()))
label = ('{:0.4g}=M('.format(objf)
+ ', '.join('{f}={v:0.4g}'.format(f=f, v=v) for f, v in zip(parset.name, parset))
+ ')')
self.lines.extend(self.ax.plot(sim, '-', label=label))
self.ax.legend()
self.ax.set_title(type(self.setup).__name__)
plt.draw()
示例3: _show_video
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import draw [as 别名]
def _show_video(video, fps=10):
# Import matplotlib/pylab only if needed
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pylab as pl
pl.style.use('ggplot')
pl.axis('off')
if fps < 0:
fps = 25
video /= 255. # Pylab works in [0, 1] range
img = None
pause_length = 1. / fps
try:
for f in range(video.shape[0]):
im = video[f, :, :, :]
if img is None:
img = pl.imshow(im)
else:
img.set_data(im)
pl.pause(pause_length)
pl.draw()
except:
pass
示例4: mpl_runner
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import draw [as 别名]
def mpl_runner(safe_execfile):
"""Factory to return a matplotlib-enabled runner for %run.
Parameters
----------
safe_execfile : function
This must be a function with the same interface as the
:meth:`safe_execfile` method of IPython.
Returns
-------
A function suitable for use as the ``runner`` argument of the %run magic
function.
"""
def mpl_execfile(fname,*where,**kw):
"""matplotlib-aware wrapper around safe_execfile.
Its interface is identical to that of the :func:`execfile` builtin.
This is ultimately a call to execfile(), but wrapped in safeties to
properly handle interactive rendering."""
import matplotlib
import matplotlib.pylab as pylab
#print '*** Matplotlib runner ***' # dbg
# turn off rendering until end of script
is_interactive = matplotlib.rcParams['interactive']
matplotlib.interactive(False)
safe_execfile(fname,*where,**kw)
matplotlib.interactive(is_interactive)
# make rendering call now, if the user tried to do it
if pylab.draw_if_interactive.called:
pylab.draw()
pylab.draw_if_interactive.called = False
return mpl_execfile