Example #1
0
def demo():
    from numpy import arange, sin, cos, pi
    from pylab import subplot, plot, axis, show
    from ginput_rect import ginput_rect

    subplot(111)
    # If N is large one can see improvement by blitting!
    N = 100000
    x = 10.0 * arange(N) / (N - 1)

    plot(x, sin(.2 * pi * x), lw=3, c='b', alpha=.7)
    plot(x, cos(.2 * pi * x), lw=3.5, c='r', alpha=.5)
    plot(x, -sin(.2 * pi * x), lw=3.5, c='g', alpha=.3)
    print "\n      click  -->  release"

    x1, x2, y1, y2 = ginput_rect(autoRemove=False)
    print "(%3.2f, %3.2f) --> (%3.2f, %3.2f)" % (x1, y1, x2, y2)

    axis([x1, x2, y1, y2])
    show()
Example #2
0
def demo():
    from numpy import arange, sin, cos, pi
    from pylab import subplot, plot, axis, show
    from ginput_rect import ginput_rect

    subplot(111)
    # If N is large one can see improvement by blitting!
    N=100000
    x=10.0*arange(N)/(N-1)

    plot(x,sin(.2*pi*x),lw=3,c='b',alpha=.7)
    plot(x,cos(.2*pi*x),lw=3.5,c='r',alpha=.5)
    plot(x,-sin(.2*pi*x),lw=3.5,c='g',alpha=.3)
    print "\n      click  -->  release"

    x1,x2,y1,y2 = ginput_rect(autoRemove = False)
    print "(%3.2f, %3.2f) --> (%3.2f, %3.2f)"%(x1,y1,x2,y2)

    axis([x1, x2, y1, y2])
    show()
Example #3
0
    def autoScale(self,event):

        x1,x2,z1,z2 = ginput_rect(self.datamyImage)
Example #4
0
"""
Select a region of the graph.

ginput_rect(ax) selects a region from the axes and continues with the plot.

s = BlockingRectangleSelector(ax) adds a rectangle selector to the axes and
lets the script call s.select() whenever a new region is needed.

demo() shows the selector in action.
"""
from matplotlib.pyplot import gca
from matplotlib.widgets import RectangleSelector
from matplotlib.blocking_input import BlockingInput
import pylab


class BlockingRectangleSelector:
    """
    Blocking rectangle selector selects once then continues with script.
    """
    def __init__(self, ax=None):
        if ax is None: ax = gca()
        self.ax = ax

        # drawtype is 'box' or 'line' or 'none'
        self.selector = RectangleSelector(self.ax,
                                          self._callback,
                                          drawtype='box',
                                          useblit=True,
                                          minspanx=5,
Example #5
0
"""
Select a region of the graph.

ginput_rect(ax) selects a region from the axes and continues with the plot.

s = BlockingRectangleSelector(ax) adds a rectangle selector to the axes and
lets the script call s.select() whenever a new region is needed.

demo() shows the selector in action.
"""
from matplotlib.pyplot import gca
from matplotlib.widgets import RectangleSelector
from matplotlib.blocking_input import BlockingInput
import pylab
class BlockingRectangleSelector:
    """
    Blocking rectangle selector selects once then continues with script.
    """
    def __init__(self, ax=None):
        if ax is None: ax=gca()
        self.ax = ax

        # drawtype is 'box' or 'line' or 'none'
        self.selector = RectangleSelector(self.ax, self._callback,
                               drawtype='box',useblit=True,
                               minspanx=5,minspany=5,spancoords='pixels')
        self.selector.set_active(False)
        self.block = BlockingInput(self.ax.figure)