Esempio n. 1
0
 def _GetRangesInWorldCords(self):
     """ _GetRangesInWorldCords()
     Get the ranges, but expressed in world coordinates rather
     than pixel coordinates in the 2D texture object.
     """
     data = self._data
     rangex = vv.Range(
         data.origin[1] + (self._rangex.min - 0.5) * data.sampling[1],
         data.origin[1] + (self._rangex.max - 0.5) * data.sampling[1])
     rangey = vv.Range(
         data.origin[0] + (self._rangey.min - 0.5) * data.sampling[0],
         data.origin[0] + (self._rangey.max - 0.5) * data.sampling[0])
     return rangex, rangey
Esempio n. 2
0
    def calculate_violin(self):

        # Get stats
        stats = self._stats

        # Get kernel density estimate
        nbins = stats.best_number_of_bins(8, 128)
        centers, values = stats.kde(nbins)

        # Normalize values
        values = values * (0.5 * self._width / values.max())

        # Create array with locations
        n = values.size
        points = np.zeros((n * 2 + 1, 3), np.float32)
        points[:n, 0] = values
        points[:n, 1] = centers
        points[n:2 * n, 0] = -np.flipud(values)
        points[n:2 * n, 1] = np.flipud(centers)
        points[2 * n, 0] = values[0]
        points[2 * n, 1] = centers[0]
        #
        self._points = points

        # Update limits
        self._limits = vv.Range(centers[0], centers[-1])
Esempio n. 3
0
    def __init__(self, parent, data, snap=True):
        vv.Wobject.__init__(self, parent)

        # Store reference to 2D anisotropic array
        self._data = data
        self._snap = snap

        # Init range as integers
        self._rangex = vv.Range(0, data.shape[1])
        self._rangey = vv.Range(0, data.shape[0])

        # How wide the bar should be
        self._barWidth = 10

        # Color to display
        self._clr1 = (0.3, 1.0, 0.3)  # line and highlighted bars
        self._clr2 = (0.0, 0.6, 0.0)  # non-active bars

        # To indicate dragging
        self._over = False
        self._dragging = False
        self._refBars = []
        self._refpos = (0, 0)
        self._refRangex = vv.Range(0, 0)
        self._refRangey = vv.Range(0, 0)

        # Quad indices of bars
        self._bar1 = [11, 6, 13, 12]
        self._bar2 = [5, 13, 14, 8]
        self._bar3 = [10, 7, 14, 15]
        self._bar4 = [4, 9, 15, 12]

        # Buffer of the coords array
        self._cordsBuffer = None

        # Create event
        self.eventRangeUpdated = vv.events.BaseEvent(self)

        # Callbacks
        self.eventEnter.Bind(self._OnEnter)
        self.eventLeave.Bind(self._OnLeave)
        self.eventMouseDown.Bind(self._OnDown)
        self.eventMouseUp.Bind(self._OnUp)
        axes = self.GetAxes()
        axes.eventMotion.Bind(self._onMotion)
        axes.eventPosition.Bind(self._onPosition)
Esempio n. 4
0
 def _getVertexLimits(self, vertices):
     ranges = []
     for i in range(3):
         X = vertices[:,i]
         I, = np.where( np.logical_not(np.isnan(X) | np.isinf(X)) )
         R = vv.Range(X[I].min(), X[I].max())
         ranges.append(R)
     return ranges
Esempio n. 5
0
    def calculate(self):
        """ calculate()
        
        Calculate the stats, and storing them such that they can
        be drawn easily. 
        
        """

        # Init limts
        self._limits = vv.Range(self._stats.dmin, self._stats.dmax)

        # Calculate more?
        if isinstance(self._whiskers, float):
            self.calculate_outliers()
        elif self._whiskers == 'violin':
            self.calculate_violin()
        else:
            pass  # we have all the info we need
Esempio n. 6
0
 def set_lims(self, rangeTheta, rangeR):
     self.axes.axis.SetLimits(rangeTheta=vv.Range(rangeTheta),
                              rangeR=vv.Range(rangeR))
Esempio n. 7
0
angsRads = np.pi * angs / 180.0

# Define magnitude
mag = 10 * np.log10(np.abs(np.sin(10 * angsRads) / angsRads)) + angsRads
mag = mag - np.max(mag)

# Plot two versions of the signal, one rotated by 20 degrees
vv.polarplot(angs, mag, lc='b')
vv.polarplot(angs + 20, mag, lc='r', lw=2)

# Set axis properties
ax = vv.gca()

ax.axis.angularRefPos = 90  # 0 deg points up
ax.axis.isCW = False  # changes angular sense (azimuth instead of phi)
ax.axis.SetLimits(rangeTheta=0, rangeR=vv.Range(-40, 5))

ax.axis.xLabel = 'degrees'
ax.axis.yLabel = 'dB'
ax.axis.showGrid = True

# Show some messages
print('drag mouse left button left-right to rotate plot.')
print('shift-drag mouse left button up-down to change lower')
print('radial limit. Drag mouse right button up-down to rescale')
print('radial axis while keeping lower radial limit fixed')

# Run mainloop
app = vv.use()
app.Run()