Python Examples

The following are 2 code examples for showing how to use These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module , or try the search function .

Example 1
Project: pynoddy   Author: cgre-aachen   File:    License: GNU General Public License v2.0 4 votes vote down vote up
def scatter_plot( self, **kwds ):
        Generates a scatter plot using the first 2 princpal components as axes.
         - *vectors* = True if original axes should be plotted as vectors in this space. Default is False.
         - *path* = a path to save this figure to
         - *dpi* = the dpi of the saved figure
         - *width* = the width (in inches) of the saved figure
         - *height* = the height (in inches) of the saved figure
        #get 2d subspace
        ss = self.get_subspace(n=2)
        #calculate colours
        import as cm
        scale = 255 / (max(self.groups) + 1)
        c = cm.Set1(self.groups*scale,alpha=1)
        #plot scatterplot
        fig,ax = plt.subplots()
        #plot vectors
        if (kwds.has_key('vectors')):
            if kwds['vectors'] == True:
                #calculate initial vectors (ie. identity matrix)
                for i,a in enumerate(axes):
                    x = [0,a[0]]
                    y = [0,a[1]]
    #private functions 
Example 2
Project: pyret   Author: baccuslab   File:    License: MIT License 4 votes vote down vote up
def plot_cells(cells, dx=1.0, **kwargs):
    Plot the spatial receptive fields for multiple cells.

    cells : list of array_like
        A list of spatiotemporal receptive fields, each of which is
        a spatiotemporal array.

    dx : float, optional
        The spatial sampling rate of the STA, setting the scale of the
        x- and y-axes.

    ax : matplotlib Axes object, optional
        The axes onto which the ellipse should be plotted.
        Defaults to a new figure.

    fig : matplotlib.figure.Figure
        The figure onto which the ellipses are plotted.

    ax : matplotlib.axes.Axes
        The axes onto which the ellipses are plotted.
    _ = kwargs.pop('fig')
    ax = kwargs.pop('ax')
    colors = cm.Set1(np.random.rand(len(cells),))

    # for each cell
    for color, sta in zip(colors, cells):

        # get the spatial profile
            spatial_profile = ft.decompose(sta)[0]
        except np.linalg.LinAlgError:

        # plot ellipse
            ellipse(spatial_profile, fc=color, ec=color,
                    lw=2, dx=dx, alpha=0.3, ax=ax)
        except RuntimeError: