numpy.c_

Here are the examples of the python api numpy.c_ taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

151 Examples 7

Example 151

Project: apsg
Source File: plotting.py
View license
    def cla(self):
        """Clear projection"""
        # now ok
        self.fig.clear()
        self.ax = self.fig.add_subplot(111)
        self.ax.format_coord = self.format_coord
        self.ax.set_aspect('equal')
        self.ax.set_autoscale_on(False)
        triangle = np.c_[self.A, self.B, self.C, self.A]
        n = 10
        tick_size = 0.2
        margin = 0.05
        self.ax.set_axis_off()
        plt.axis([self.A[0]-margin, self.B[0]+margin, self.C[1]-margin, self.A[1]+margin])

        # Projection triangle
        bg = plt.Polygon([self.A, self.B, self.C], color='w', edgecolor=None)
        self.ax.add_patch(bg)
        self.ax.plot(triangle[0], triangle[1], 'k', lw=2)
        self.ax.text(self.A[0]-0.02, self.A[1],'P', ha='right', va='bottom', fontsize=14)
        self.ax.text(self.B[0]+0.02, self.B[1],'G', ha='left', va='bottom', fontsize=14)
        self.ax.text(self.C[0], self.C[1]-0.02,'R', ha='center', va='top', fontsize=14)

        if self.grid:
            for l in np.arange(0.1,1,0.1):
                self.triplot([l, l], [0, 1-l], [1-l, 0], 'k:')
                self.triplot([0, 1-l], [l, l], [1-l, 0], 'k:')
                self.triplot([0, 1-l], [1-l, 0], [l, l], 'k:')

        # ticks
        if self.ticks:
            r = np.linspace(0, 1, n+1)
            tick = tick_size * (self.B - self.C) / n
            x = self.A[0] * (1 - r) + self.B[0] * r
            x = np.vstack((x, x + tick[0]))
            y = self.A[1] * (1 - r) + self.B[1] * r
            y = np.vstack((y, y + tick[1]))
            self.ax.plot(x, y, 'k', lw=1)
            tick = tick_size * (self.C - self.A) / n
            x = self.B[0] * (1 - r) + self.C[0] * r
            x = np.vstack((x, x + tick[0]))
            y = self.B[1] * (1 - r) + self.C[1] * r
            y = np.vstack((y, y + tick[1]))
            self.ax.plot(x, y, 'k', lw=1)
            tick = tick_size * (self.A - self.B) / n
            x = self.A[0] * (1 - r) + self.C[0] * r
            x = np.vstack((x, x + tick[0]))
            y = self.A[1] * (1 - r) + self.C[1] * r
            y = np.vstack((y, y + tick[1]))
            self.ax.plot(x, y, 'k', lw=1)
        self.ax.set_title('Fabric plot')
        self.draw()