本文整理汇总了Python中matplotlib.pyplot.fignum_exists函数的典型用法代码示例。如果您正苦于以下问题:Python fignum_exists函数的具体用法?Python fignum_exists怎么用?Python fignum_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fignum_exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_nominal
def test_nominal(self):
fig1 = plt.figure()
fig2 = plt.figure()
self.assertTrue(plt.fignum_exists(fig1.number))
self.assertTrue(plt.fignum_exists(fig2.number))
dcs.close_all()
self.assertFalse(plt.fignum_exists(fig1.number))
self.assertFalse(plt.fignum_exists(fig2.number))
开发者ID:superbeckgit,项目名称:dstauffman,代码行数:8,代码来源:test_plotting.py
示例2: _Plot_3D_fired
def _Plot_3D_fired(self):
try:
plt.fignum_exists()
xmin, xmax = plt.xlim()
ymin, ymax = plt.ylim()
index_wavelength_left=(np.abs(Data.wavelength-xmin)).argmin()
index_wavelength_right=(np.abs(Data.wavelength-xmax)).argmin()
index_time_left=(np.abs(Data.time-ymin)).argmin()
index_time_right=(np.abs(Data.time-ymax)).argmin()
except:
index_wavelength_left=0
index_wavelength_right=Data.wavelength[-1]
index_time_left=0
index_time_right=Data.wavelength[-1]
Data.Three_d = Data.TrA_Data[index_time_left:index_time_right,index_wavelength_left:index_wavelength_right]
Data.Three_d_wavelength = Data.wavelength[index_wavelength_left:index_wavelength_right]
Data.Three_d_time = Data.time[index_time_left:index_time_right]
self.scene.mlab.clf()
x = np.linspace(Data.Three_d_wavelength[0],Data.Three_d_wavelength[-1],len(Data.Three_d_wavelength))
y = np.linspace(Data.Three_d_time[0], Data.Three_d_time[-1],len(Data.Three_d_wavelength))
[xi,yi] = np.meshgrid(x,y)
for i in range(len(Data.Three_d_wavelength)):
repeating_wavelength = np.array(np.ones((len(Data.Three_d_time)))*Data.Three_d_wavelength[i])
vectors = np.array([Data.Three_d_time,repeating_wavelength,Data.Three_d[:,i]])
if i==0:
Data.TrA_Data_gridded = vectors
else:
Data.TrA_Data_gridded = np.hstack((Data.TrA_Data_gridded, vectors))
zi = interpolate.griddata((Data.TrA_Data_gridded[1,:],Data.TrA_Data_gridded[0,:]),Data.TrA_Data_gridded[2,:],(xi,yi), method='linear', fill_value=0)
#Sends 3D plot to mayavi in gui
#uncomment for plotting actual data matrix
#self.scene.mlab.surf(Data.time,Data.wavelength,Data.TrA_Data,warp_scale=-self.z_height*100)
#gridded plot which gives correct view
self.plot = self.scene.mlab.surf(yi,xi,zi, warp_scale=-self.z_height*100)
self.scene.mlab.colorbar(orientation="vertical")
self.scene.mlab.axes(nb_labels=5,)
self.scene.mlab.ylabel("wavelength (nm)")
self.scene.mlab.xlabel("time (ps)")
开发者ID:Margauxair,项目名称:PyTrA,代码行数:50,代码来源:PyTrA.py
示例3: plot_process
def plot_process(queue, name, labels=None):
"""Grabs data from the queue and plots it in a named figure
"""
# Set up the figure and display it
fig = setup_figure(name)
plt.show(block=False)
if labels is not None:
plt.xlabel(labels[0])
plt.ylabel(labels[1])
while True:
# Get all the data currently on the queue
data = []
while not queue.empty():
data.append(queue.get())
# If there is no data, no need to plot, instead wait for a
# while
if len(data) == 0:
plt.pause(0.015)
continue
# Check if poison pill (None) arrived or the figure was closed
if None in data or not plt.fignum_exists(fig.number):
# If yes, leave the process
break
else:
# Plot the data, then wait 15ms for the plot to update
for datum in data:
plt.plot(*datum)
plt.pause(0.015)
开发者ID:kinverarity1,项目名称:pyexperiment,代码行数:31,代码来源:plot.py
示例4: savefig
def savefig(filename, **kwargs):
"""
Save a figure plotted by Matplotlib.
Note : This function is supposed to be used after the ``plot``
function. Otherwise it will save a blank image with no plot.
Parameters
----------
filename : str
The name of the image file. Extension must be specified in the
file name. For example filename with `.png` extension will give a
rasterized image while `.pdf` extension will give a vectorized
output.
kwargs : keyword arguments
Keyword arguments to be passed to ``savefig`` function of
``matplotlib.pyplot``. For example use `bbox_inches='tight'` to
remove the undesirable whitepace around the image.
"""
try:
import matplotlib.pyplot as plt
except ImportError:
raise ImportError("Matplotlib required for savefig()")
if not plt.fignum_exists(1):
utils.simon("use ``plot`` function to plot the image first and "
"then use ``savefig`` to save the figure.")
plt.savefig(filename, **kwargs)
开发者ID:OrkoHunter,项目名称:stingray,代码行数:31,代码来源:io.py
示例5: make_new_fig
def make_new_fig(fnum=None, close_old=True, return_fig=False,
use_max_fnum=False, **kwargs):
"""
Make a new figure, clearing the old one.
Returns the figure after the one you've created.
"""
if fnum is None:
fignums = get_fignums()
max_fnum = max(fignums) if len(fignums) > 0 else 0
if use_max_fnum:
fnum = max_fnum+1
else:
for fnum in range(0, max_fnum+2):
if fnum not in fignums:
break
if fignum_exists(fnum) and close_old:
close(fnum) # Close the figure if it already exists.
fig = figure(fnum, **kwargs)
clf()
if return_fig:
return [fig, fnum+1]
else:
return fnum+1
开发者ID:pganssle-research,项目名称:alkali-vapor-cell-magnetometry-dissertation,代码行数:29,代码来源:figure_settings.py
示例6: gplot
def gplot(xval, yval, sym=None, xr=None, yr=None, title=None, xlabel=None, \
ylabel=None, tsize=None, xsize=None, ysize=None, color=None, \
fnum=None, fname=None):
# -------- defaults
if sym==None : sym='k-'
if xr==None : xr = min(xval), max(xval)
if yr==None : yr = min(yval), max(yval)
if title==None : title=''
if xlabel==None : xlabel=''
if ylabel==None : ylabel=''
if fnum==None : fnum=0
# -------- make the figure
if plt.fignum_exists(fnum): plt.close(fnum)
plt.figure(fnum)
plt.plot(xval,yval,sym)
plt.xlim(xr)
plt.ylim(yr)
plt.title(title, fontsize=tsize)
plt.xlabel(xlabel, fontsize=xsize)
plt.ylabel(ylabel, fontsize=ysize)
# -------- write to output if desired
if fname!=None:
if not isinstance(fname,list): fname = [fname]
for ifile in fname:
print("GPLOT: Writing output to " + ifile)
plt.savefig(ifile)
else:
plt.show()
开发者ID:gdobler,项目名称:glib,代码行数:35,代码来源:gplot.py
示例7: mpl_annotate_interactive
def mpl_annotate_interactive(text, ax=None, arrowprops={"facecolor":'black', "shrink":0.05}):
ax = ax or pyplot.gca()
fig = ax.figure
coordinates = [
None, # xy
None # xytext
]
pause = [True,]
def get_xy(event):
if coordinates[0] is None:
coordinates[0] = (event.x, event.y)
print("xy : {}".format(coordinates[0]))
else:
coordinates[1] = (event.x, event.y)
print("xytext : {}".format(coordinates[1]))
pause[0] = False
cid = fig.canvas.mpl_connect('button_press_event', get_xy)
while pause[0] and pyplot.fignum_exists(fig.number):
fig.canvas.get_tk_widget().update()
fig.canvas.mpl_disconnect(cid)
ax.annotate(
text,
xycoords='figure pixels',
xy=coordinates[0],
xytext=coordinates[1],
arrowprops=arrowprops,
)
开发者ID:sandeep9373,项目名称:Devel,代码行数:27,代码来源:pylab_helpers.py
示例8: closeFigure
def closeFigure(event): #remove figure from figs
for figure in figs:
if not plt.fignum_exists(figure[0]): #if figure id number doesn't exist, figure doesn't exist
print("removing figure",figure[0])
figs.remove(figure) #remove from figure list
if len(figs) == 0:
raise SystemExit #exit program if all figures have been closed
开发者ID:EDQscripts,项目名称:Expert_coding_app,代码行数:8,代码来源:plotEyeData_v0.743.py
示例9: mpl_wait_for_key_press
def mpl_wait_for_key_press(fig=None, key="enter", close=False):
# I need to use an object. The pointer to the pause list will be captured by
# closer in key_press_event. When the callback will change the pause
# content, the outer function will see it. With the simple pause = True
# code, the inner function would have changed a local copy of pause.
if fig is None:
fig = pyplot.gcf()
pause = [True, ]
def key_press_event(event):
if event.key == key:
pause[0] = False
cid = fig.canvas.mpl_connect('key_press_event', key_press_event)
while pause[0] and pyplot.fignum_exists(fig.number):
fig.canvas.get_tk_widget().update()
fig.canvas.mpl_disconnect(cid)
if close and pyplot.fignum_exists(fig.number):
pyplot.close(fig.number)
开发者ID:sandeep9373,项目名称:Devel,代码行数:17,代码来源:pylab_helpers.py
示例10: _redraw
def _redraw(self):
if plt.isinteractive():
fig = self.kwargs["fig"]
if not plt.fignum_exists(fig.number):
fig.show()
fig.canvas.draw()
else:
print("Redraw() is unsupported in non-interactive plotting mode!")
开发者ID:lowks,项目名称:justplot,代码行数:8,代码来源:justplot.py
示例11: test_filter_applyFilter
def test_filter_applyFilter(self):
ppmm = self.runBefore()
fake_event = matplotlib.backend_bases.MouseEvent('button_press_event', ppmm.figfilter.canvas, 636, 823)
ppmm.applyFilter(fake_event)
# check the figure has been closed
self.assertFalse(py.fignum_exists(ppmm.figfilter.number))
开发者ID:pysmo,项目名称:aimbat,代码行数:8,代码来源:qualctrl_tests.py
示例12: _redraw
def _redraw(self):
if plt.isinteractive():
fig = self.kwargs.get('fig',False)
if not fig: return
if not plt.fignum_exists(fig.number):
fig.show()
fig.canvas.draw()
else:
print('Redraw() is unsupported in non-interactive plotting mode!')
开发者ID:OnionNinja,项目名称:justplot,代码行数:9,代码来源:justplot.py
示例13: updateTimeUnit
def updateTimeUnit(self,event):
#Verify that the data frame is not empty
if self.df.empty:
messagebox.showinfo('Selection Error', 'Error: Please collect data before selecting time units.')
else:
self.unit = self.timevar.get()
self.unit_conv = self.choices[self.unit]
#Change units on timestamp plots if they exist
self.df['timestamp']=self.df['orig_timestamp'] * self.unit_conv
#Figure two is the EvT plot:
if plt.fignum_exists(2):
self.EvT_plot()
#Figure one is the Time Histogram
if plt.fignum_exists(1):
self.THist_plot()
开发者ID:Raknoche,项目名称:MyCode,代码行数:18,代码来源:radonGUI.py
示例14: display
def display(self, image):
if self.imsh is None or not plt.fignum_exists(self.imsh.figure.number):
self.imsh = plt.imshow(image, interpolation='nearest')
self.imsh.axes.axis('off')
self.imsh.axes.set_position((0, 0, 1, 1))
self.imsh.figure.canvas.draw()
else:
self.imsh.set_data(image)
plt.pause(1e-4)
开发者ID:crowsonkb,项目名称:style_transfer,代码行数:9,代码来源:display_image.py
示例15: animation
def animation():
for i1 in xrange(1, nanim):
# remove previous highlights
icontainer.ax0_hs.remove()
icontainer.ax1_hs.get_sizes()[0] = 20
icontainer.ax1_hs.get_facecolor()[0,0] = 0
icontainer.ax1_hs.get_facecolor()[0,1] = 0.5
icontainer.ax1_hs.get_facecolor()[0,3] = 0.2
icontainer.ax1_hs.get_edgecolor()[0,1] = 0.5
icontainer.ax1_hs.get_edgecolor()[0,3] = 0.2
# remove previous predictive distribution
axes[1].lines.remove(icontainer.prev_line)
# show next sample
icontainer.ax0_hs = axes[0].scatter(mu[i1], sigma[i1], 40, 'r')
icontainer.ax1_hs = axes[1].scatter(
ynew[i1], (0.02 + 0.02*np.random.rand())*np.max(ynewdists), 40, 'r'
)
icontainer.prev_line, = axes[1].plot(
xynew, ynewdists[i1], 'b', linewidth=1.5
)
# update figure
fig.canvas.draw()
# wait animation delay time or until animation is cancelled
stop_anim.wait(anim_delay)
if stop_anim.isSet():
# animation cancelled
break
# skip the rest if the figure does not exist anymore
if not plt.fignum_exists(fig.number):
return
# advance stage
icontainer.stage += 1
# remove highlights
icontainer.ax0_hs.remove()
axes[1].lines.remove(icontainer.prev_line)
icontainer.ax1_hs.get_sizes()[0] = 20
icontainer.ax1_hs.get_facecolor()[0,0] = 0
icontainer.ax1_hs.get_facecolor()[0,1] = 0.5
icontainer.ax1_hs.get_facecolor()[0,3] = 0.2
icontainer.ax1_hs.get_edgecolor()[0,1] = 0.5
icontainer.ax1_hs.get_edgecolor()[0,3] = 0.2
# modify helper text
htext.set_text('press any key to continue')
# plot the rest of the samples
i1 += 1
icontainer.ax1_hs = axes[1].scatter(
ynew[i1:], (0.02 + 0.015*np.random.rand(nsamp-i1))*np.max(ynewdists), 10,
color=[0,0.5,0], alpha=0.2
)
# update legend
axes[1].legend(
(icontainer.ax1_hs,),
('samples from the predictive distribution',),
loc='upper center'
)
fig.canvas.draw()
开发者ID:GeorgeMcIntire,项目名称:BDA_py_demos,代码行数:56,代码来源:demo3_4.py
示例16: _figure_name
def _figure_name(base_name):
"""Helper to compute figure name
This takes in a base name an return the name of the figure to use.
If gs.OVERPLOT, then this is a no-op. If not gs.OVERPLOT then append '(N)'
to the end of the string until a non-existing figure is found
"""
if not gs.OVERPLOT:
if not plt.fignum_exists(base_name):
pass
else:
for j in itertools.count(1):
numbered_template = '{} ({})'.format(base_name, j)
if not plt.fignum_exists(numbered_template):
base_name = numbered_template
break
return base_name
开发者ID:danielballan,项目名称:bluesky,代码行数:19,代码来源:spec_api.py
示例17: EvT_select
def EvT_select (self):
#Verify that the data frame is not empty
if self.df.empty:
messagebox.showinfo('Plot Error', 'Error: No data has been collected. Can not select absent data.')
elif not plt.fignum_exists(2):
messagebox.showinfo('Plot Error', 'Please open the EvT plot before trying to select data.')
else:
plt.figure(2)
plt.scatter(self.df['timestamp'],self.df['amplitude'],color=self.EvT_color_set,s=self.EvT_size_set)
self.EvT_interface = PlotInterface(self.df,self.EvT_color_set,self.EvT_size_set)
开发者ID:Raknoche,项目名称:MyCode,代码行数:10,代码来源:radonGUI.py
示例18: test_filter_unapplyFilter
def test_filter_unapplyFilter(self):
ppmm = self.runBefore()
event_apply = matplotlib.backend_bases.MouseEvent('button_press_event', ppmm.figfilter.canvas, 636, 823)
ppmm.applyFilter(event_apply)
event_unapply = matplotlib.backend_bases.MouseEvent('button_press_event', ppmm.figfilter.canvas, 538, 838)
ppmm.unapplyFilter(event_unapply)
self.assertFalse(ppmm.opts.filterParameters['apply'])
self.assertFalse(py.fignum_exists(ppmm.figfilter.number))
开发者ID:pysmo,项目名称:aimbat,代码行数:11,代码来源:qualctrl_tests.py
示例19: closeFigure
def closeFigure(event): #remove figure from figs
for figure in figs:
if not plt.fignum_exists(figure[0]): #if figure id number doesn't exist, figure doesn't exist
print("removing figure",figure[0])
figs.remove(figure) #remove from figure list
if len(figs) == 0:
if sys.platform == 'darwin': #only on Macs
email_data(self.csvFileName, self.coder)
raise SystemExit #exit program if all figures have been closed
开发者ID:EDQscripts,项目名称:Expert_coding_app,代码行数:12,代码来源:expertCodingApp_v0.9.9.3.py
示例20: showMap
def showMap(self,block = False ):
if not plt.fignum_exists(1):
self.imgplot = plt.imshow(self.map,interpolation = 'none', cmap = 'gray_r')
plt.show(block = block)
plt.grid(1)
plt.ion()
print 'does not exist'
raw_input()
else:
self.imgplot.set_data(self.map)
plt.draw()
print 'exists'
开发者ID:chiragmajithia,项目名称:quadtree,代码行数:12,代码来源:Map.py
注:本文中的matplotlib.pyplot.fignum_exists函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论