本文整理汇总了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