本文整理匯總了Python中matplotlib.pyplot.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.connect方法的具體用法?Python pyplot.connect怎麽用?Python pyplot.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.connect方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: hzfunc
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import connect [as 別名]
def hzfunc(self,label):
ax = self.hzdict[label]
num = int(label.replace("plot ",""))
#print "Selected axis number:", num
#global mainnum
self.mainnum = num
# drawtype is 'box' or 'line' or 'none'
toggle_selector.RS = RectangleSelector(ax, self.line_select_callback,
drawtype='box', useblit=True,
button=[1,3], # don't use middle button
minspanx=5, minspany=5,
spancoords='pixels',
rectprops = dict(facecolor='red', edgecolor = 'black', alpha=0.2, fill=True))
#plt.connect('key_press_event', toggle_selector)
plt.draw()
示例2: __init__
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import connect [as 別名]
def __init__(self, filename):
self.filename = filename
self.image_data = cv2.imread(filename, 0)
fig_image, current_ax = plt.subplots()
plt.imshow(self.image_data, cmap='gray')
eh = EventHandler(self.filename)
rectangle_selector = RectangleSelector(current_ax,
eh.line_select_callback,
drawtype='box',
useblit=True,
button=[1, 2, 3],
minspanx=5, minspany=5,
spancoords='pixels',
interactive=True)
plt.connect('key_press_event', eh.event_exit_manager)
plt.show()
示例3: markpoints
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import connect [as 別名]
def markpoints(self, dataarray,keyarray):
for idx,elem in enumerate(dataarray):
key = keyarray[idx]
#print "Selected curve - markpoints:", idx
#print dataarray[idx]
if not idx == 0 and not len(elem) == 0 and key in self.keylist: #FLAGKEYLIST:
#print ( idx, self.axlist[idx-1] )
ax = self.axlist[idx-1]
#ax.clear()
#ax.text(dataarray[0][1],dataarray[1][1], "(%s, %3.2f)"%("Hello",3.67), )
ax.scatter(dataarray[0].astype('<f8'),elem.astype('<f8'), c='r', zorder=100) #, marker='d', c='r') #, zorder=100)
#plt.connect('key_press_event', toggle_selector)
plt.draw()
示例4: show
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import connect [as 別名]
def show(self):
# Read and draw image
dpi = 80
w = 16
h = 9
self.fig = plt.figure(figsize=(w, h), dpi=dpi)
self.ax = self.fig.add_axes([0.0, 0.0, 1.0, 1.0], frameon=False)
if len(self.image_paths) > 1:
plt.connect('key_release_event', self.next_image)
self.show_image()
plt.show()
示例5: __init__
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import connect [as 別名]
def __init__(self, im, materials):
"""
Args:
im (ndarray): Pixels of the image.
materials (list): To store selected RGB(A) values of selected pixels.
"""
self.im = im
self.materials = materials
plt.connect('button_press_event', self)
示例6: startup
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import connect [as 別名]
def startup(self, fig, data):
print("--------------------------------------------")
print(" you started the build-in flagging function")
print("--------------------------------------------")
print(" -- use mouse to select rectangular areas")
print(" -- press f for flagging this region")
print(" -- press 2,3 to change default flag ID")
print(" -- press l to get some basic data info")
print(" -- press o to apply an offset")
print(" -- press h to get all meta information")
print(" -- press c to close the window and allow saving")
# Arrays to exchange data
self.selarray = []
# Globals
self.idxar = [] # holds all selected index values
#mainnum = 1 # holds the selected figure axis
self.axlist = fig.axes
# #############################################################
## Adding Radiobttons to switch selector between different plot
# #############################################################
plt.subplots_adjust(left=0.2)
axcolor = 'lightgoldenrodyellow'
rax = plt.axes([0.02, 0.8, 0.10, 0.15])
rax.patch.set_facecolor(axcolor)
# create dict and list
numlst = ['plot '+str(idx+1) for idx,elem in enumerate(self.axlist)]
## python 2.7 and higher
# self.hzdict = {'plot '+str(idx+1):elem for idx,elem in enumerate(self.axlist)}
## python 2.6 and lower
self.hzdict = dict(('plot '+str(idx+1),elem) for idx,elem in enumerate(self.axlist))
radio = RadioButtons(rax, numlst)
# #############################################################
## Getting a rectangular selector
# #############################################################
toggle_selector.RS = RectangleSelector(self.axlist[0], self.line_select_callback, drawtype='box', useblit=True,button=[1,3],minspanx=5, minspany=5,spancoords='pixels', rectprops = dict(facecolor='red', edgecolor = 'black', alpha=0.2, fill=True))
plt.connect('key_press_event', self.toggle_selector)
return radio, self.hzfunc