def curvelinear_test1(fig):
    """
    grid for custom transform.
    """

    def tr(x, y):
        x, y = np.asarray(x), np.asarray(y)
        return x, y-x

    def inv_tr(x,y):
        x, y = np.asarray(x), np.asarray(y)
        return x, y+x


    grid_helper = GridHelperCurveLinear((tr, inv_tr))

    ax1 = Subplot(fig, 1, 2, 1, grid_helper=grid_helper)
    # ax1 will have a ticks and gridlines defined by the given
    # transform (+ transData of the Axes). Note that the transform of
    # the Axes itself (i.e., transData) is not affected by the given
    # transform.

    fig.add_subplot(ax1)

    xx, yy = tr([3, 6], [5.0, 10.])
    ax1.plot(xx, yy)

    ax1.set_aspect(1.)
    ax1.set_xlim(0, 10.)
    ax1.set_ylim(0, 10.)

    ax1.axis["t"]=ax1.new_floating_axis(0, 3.)
    ax1.axis["t2"]=ax1.new_floating_axis(1, 7.)
    ax1.grid(True)
예제 #2
0
def curvelinear_test1(fig):
    """
    grid for custom transform.
    """
    def tr(x, y):
        x, y = np.asarray(x), np.asarray(y)
        return x, y - x

    def inv_tr(x, y):
        x, y = np.asarray(x), np.asarray(y)
        return x, y + x

    grid_helper = GridHelperCurveLinear((tr, inv_tr))

    ax1 = Subplot(fig, 1, 2, 1, grid_helper=grid_helper)
    # ax1 will have a ticks and gridlines defined by the given
    # transform (+ transData of the Axes). Note that the transform of
    # the Axes itself (i.e., transData) is not affected by the given
    # transform.

    fig.add_subplot(ax1)

    xx, yy = tr([3, 6], [5.0, 10.])
    ax1.plot(xx, yy)

    ax1.set_aspect(1.)
    ax1.set_xlim(0, 10.)
    ax1.set_ylim(0, 10.)

    ax1.grid(True)
예제 #3
0
def curvelinear_test1(fig):
    """
    grid for custom transform.
    """
    def tr(x, y):
        x, y = np.asarray(x), np.asarray(y)
        return x, y-x
    def inv_tr(x,y):
        x, y = np.asarray(x), np.asarray(y)
        return x, y+x
    grid_helper = GridHelperCurveLinear((tr, inv_tr))
    ax1 = Subplot(fig, 1, 2, 1, grid_helper=grid_helper)
    fig.add_subplot(ax1)
    xx, yy = tr([3, 6], [5.0, 10.])
    ax1.plot(xx, yy)
    ax1.set_aspect(1.)
    ax1.set_xlim(0, 10.)
    ax1.set_ylim(0, 10.)
    ax1.grid(True)
def plottraces(atfobj):

    # plt.figure creates a matplotlib.figure.Figure instance
    fig = plt.figure()
    rect = fig.patch # a rectangle instance
    rect.set_alpha(0) # set the background of the figure to be transparent

    #use the weird Subplot imported from the toolkits to make your axes container?
    #then add this axes to to figure explicitly
    ax1 = Subplot(fig,111)
    ax1.patch.set_alpha(0) # set the background of the plotting axes to be transparent 
    fig.add_subplot(ax1)

    # this weird Subplot imported from the toolkits let you indivdually set the axis lines to be invisible
    # now I am hiding all of the axis lines
    ax1.axis["right"].set_visible(False)
    ax1.axis["top"].set_visible(False)
    ax1.axis["bottom"].set_visible(False)
    ax1.axis["left"].set_visible(False)

    ax1.plot(atfobj.data[:,1],color = 'black')
    ax1.plot(atfobj.data[:,2]+0.06, color = 'blue')
    return fig
예제 #5
0
    def PlotVollmer(self, event): 

        #initialize the plot areas
        self.dataFigure.clf()
        axes = Subplot(self.dataFigure, 111, clip_on='True',xlim=(-0.1,1.05), ylim=(-0.1,1.05),autoscale_on='True',label='vollmer',aspect='equal', adjustable='box',anchor='SW')
        self.dataFigure.add_subplot(axes)
        axes.axis["right"].set_visible(False)
        axes.axis["top"].set_visible(False)
        axes.axis["bottom"].set_visible(False)
        axes.axis["left"].set_visible(False)



        try:
            sqrt3_2 = 0.866025  #m_sqrt(3)/2

            tr1 = Line2D((0,1),(0,0),c='black')
            axes.add_line(tr1)
            tr2 = Line2D((0,0.5),(0,sqrt3_2),c='black')
            axes.add_line(tr2)
            tr3 = Line2D((1,0.5),(0,sqrt3_2),c='black')
            axes.add_line(tr3)



            for i in [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]:
                diag = Line2D((i/2,1.0-i/2),(sqrt3_2*i,sqrt3_2*i),c='grey',lw=0.5)
                axes.add_line(diag)
                diag2 = Line2D((i/2,i),(sqrt3_2*i,0),c='grey',lw=0.5)
                axes.add_line(diag2)
                diag3 = Line2D((i,i+(1-i)/2),(0,sqrt3_2-sqrt3_2*i),c='grey',lw=0.5)
                axes.add_line(diag3)


            axes.text(-0.08,-0.05,'Point',family='sans-serif',size=self.fontSize,horizontalalignment='left' )
            axes.text(0.97,-0.05,'Girdle',family='sans-serif',size=self.fontSize,horizontalalignment='left' )
            axes.text(0.5,0.88,'Random',family='sans-serif',size=self.fontSize,horizontalalignment='center' )

            # label axes values
            for i in [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]:
                axes.text((1-i)/2, sqrt3_2*(1-i)-0.01, '%d' % (i*100), family='sans-serif', size=self.fontSize, horizontalalignment='right', color='grey', rotation='60')
                axes.text(i, -0.02,'%d' % (i*100), family='sans-serif', size=self.fontSize, horizontalalignment='center', verticalalignment='top', color='grey')
                axes.text(1.0-i/2, sqrt3_2*i-0.01,'%d' % (i*100) , family='sans-serif', size=self.fontSize, horizontalalignment='left', color='grey', rotation='-60')


            # ternary plot (from wikipedia)
            # P = (0,0)
            # G = (1,0)
            # R = (1/2, sqrt(3)/2)
            # given (P,G,R):
            # x = G + R/2
            # y = (sqrt(3)/2) * R

            if len(self.idxPlan) == 0 and len(self.idxLin) == 0: # in case we have only one one opened file but it is not checked
                raise AttributeError
            else:
                for i in range(len(self.idxPlan)):
                    x = self.PeigenList[i]["G"] + (self.PeigenList[i]["R"] / 2)
                    y = self.PeigenList[i]["R"] * sqrt3_2
                    axes.plot(x,y, self.PProps[i]["PoleSymb"], c=self.PProps[i]["PolColor"], ms=self.PProps[i]["polespin"],label='%s n=%d' % (self.Pname[i],self.Pndata[i]))

                for j in range(len(self.idxLin)):
                    x = self.LeigenList[j]["G"] + (self.LeigenList[j]["R"] / 2)
                    y = self.LeigenList[j]["R"] * sqrt3_2
                    axes.plot(x,y, self.LProps[j]["LineSymb"], c=self.LProps[j]["LinColor"], ms=self.LProps[j]["linespin"],label='%s n=%d' % (self.Lname[j],self.Lndata[j]))


            axes.legend(bbox_to_anchor=(0.97, 0.8), loc=2, prop=FontProperties(size=self.fontSize),numpoints=1)

            axes.set_xlim(-0.1,1.05)
            axes.set_ylim(-0.1,1.05)
            self.dataCanvas.draw()

        except AttributeError:
            self.dataFigure.clf()
            dlg = wx.MessageDialog(None, _('No file(s) selected (checked).\n\n'), _('Oooops!'), wx.OK|wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            pass
예제 #6
0
    def PlotFlinn(self, event): 

        #initialize the plot areas
        self.dataFigure.clf()
        axes = Subplot(self.dataFigure, 111, clip_on='True',xlim=(-0.2,7.2), ylim=(-0.2,7.2),autoscale_on='True',xlabel='ln(S2/S3)',ylabel='ln(S1/S2)',label='flinn',aspect='equal', adjustable='box',anchor='W')
        self.dataFigure.add_subplot(axes)
        axes.axis["right"].set_visible(False)
        axes.axis["top"].set_visible(False)

        try:
            # plot lines of K
            for i in [0.2, 0.5, 1.0, 2.0, 5.0]:
                if i <= 1.0:
                    diag = Line2D((0,7.0),(0,(i*7.0)),c='grey',lw=0.5)
                    axes.add_line(diag)
                else:
                    diag = Line2D((0,(7.0/i)),(0,7.0),c='grey',lw=0.5)
                    axes.add_line(diag)

            # plot lines of C
            for j in [2,4,6]:
                diag2 = Line2D((0,j),(j,0),c='grey',lw=0.5)
                axes.add_line(diag2)

            # texts
            axes.text(6.25,0.05,'K = 0',family='sans-serif',size=self.fontSize,horizontalalignment='left',color='grey')
            axes.text(0.15,6.1,'K = inf.',family='sans-serif',size=self.fontSize,horizontalalignment='left',color='grey',rotation='vertical')
            axes.text(6.45,6.4,'K = 1',family='sans-serif',size=self.fontSize,horizontalalignment='center',color='grey',rotation='45')
            axes.text(3.2,6.4,'K = 2',family='sans-serif',size=self.fontSize,horizontalalignment='center',color='grey',rotation='63.5')
            axes.text(1.2,6.4,'K = 5',family='sans-serif',size=self.fontSize,horizontalalignment='center',color='grey',rotation='78.7')
            axes.text(6.4,3.1,'K = 0.5',family='sans-serif',size=self.fontSize,horizontalalignment='center',color='grey',rotation='26.6')
            axes.text(6.5,1.3,'K = 0.2',family='sans-serif',size=self.fontSize,horizontalalignment='center',color='grey',rotation='11.3')
            axes.text(2.6,3.35,'C = 6',family='sans-serif',size=self.fontSize,horizontalalignment='center',color='grey',rotation='-45')
            axes.text(1.75,2.2,'C = 4',family='sans-serif',size=self.fontSize,horizontalalignment='center',color='grey',rotation='-45')

            axes.text(3.5,3.75,'Girdle/Cluster Transition',family='sans-serif',size=self.fontSize,horizontalalignment='left',verticalalignment='bottom',color='grey',rotation='45')
            axes.text(6.5,7.2,'CLUSTERS',family='sans-serif',size=self.fontSize,horizontalalignment='right',verticalalignment='bottom',color='grey')
            axes.text(7.2,6.5,'GIRDLES',family='sans-serif',size=self.fontSize,horizontalalignment='left',verticalalignment='top',color='grey',rotation='-90')


            # plot the selected (checked) files
            # propsPList = [pdata, itemName, PolColor, symbPoles, polespin,...
            # propsLList = [pdata, itemName, LinColor, LineSymb, linespin,...

            if len(self.idxPlan) == 0 and len(self.idxLin) == 0: # in case we have only one one opened file but it is not checked
                raise AttributeError
            else:
                for i in range(len(self.idxPlan)):
                    axes.plot(self.PeigenList[i]["K_x"],self.PeigenList[i]["K_y"], self.PProps[i]["PoleSymb"], c=self.PProps[i]["PolColor"], ms=self.PProps[i]["polespin"], label='%s n=%d' % (self.Pname[i],self.Pndata[i]))

                for j in range(len(self.idxLin)):
                    axes.plot(self.LeigenList[j]["K_x"],self.LeigenList[j]["K_y"], self.LProps[j]["LineSymb"], c=self.LProps[j]["LinColor"], ms=self.LProps[j]["linespin"], label='%s n=%d' % (self.Lname[j],self.Lndata[j]))

            axes.legend(bbox_to_anchor=(1.1, 1), loc=2, prop=FontProperties(size='small'),numpoints=1)

            #set the axes limits and draws the stuff
            axes.set_xlim(0.0,7.2)
            axes.set_ylim(0.0,7.2)
            self.dataCanvas.draw()

        except AttributeError:
            self.dataFigure.clf()
            dlg = wx.MessageDialog(None, 'No file(s) selected (checked).\n\n', 'Oooops!', wx.OK|wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            pass
예제 #7
0
##     ax.axis[direction].set_visible(False)

## ax.set_xticks([])
## ax.set_yticks([])

## x = np.linspace(0, 2., 100)
## ax.plot(x, np.sin(x*np.pi))

## #fig.savefig('different_axis.pdf')
## plt.show()

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.axislines import Subplot

fig = plt.figure()

ax = Subplot(fig, 111)
fig.add_subplot(ax)

ax.axis["right"].set_visible(False)
ax.axis["left"].set_visible(False)
ax.axis["top"].set_visible(False)
ax.axis["bottom"].set_visible(False)
x = np.linspace(0, 2., 100)
ax.plot(x, np.sin(x*np.pi))
plt.tight_layout()

fig.savefig('different_axis.pdf')
#plt.show()
예제 #8
0
def generate_graph(chromosome, nearest_supers, FIELD_WIDTH, FIELD_HEIGHT,
                   graph_title, n):
    chromosome = [int(i) for i in chromosome]
    w = (FIELD_WIDTH) / 4.0
    h = (FIELD_HEIGHT) / 4.0
    fig = pylab.figure(figsize=(w + 1, h))
    #fig = pylab.figure(figsize=(2.5,3))
    #ax = pylab.subplot(111)
    ax = Subplot(fig, 111)
    fig.add_subplot(ax)

    #ax.axis["right"].set_visible(False)
    #ax.axis["top"].set_visible(False)
    #ax.axis["bottom"].set_visible(False)
    #ax.axis["left"].set_visible(False)

    super_x = [
        coords[i][0] for i in range(len(chromosome)) if (chromosome[i] == 1)
    ]
    super_y = [
        coords[i][1] for i in range(len(chromosome)) if chromosome[i] == 1
    ]
    sensor_x = [
        coords[i][0] for i in range(len(chromosome)) if chromosome[i] == 0
    ]
    sensor_y = [
        coords[i][1] for i in range(len(chromosome)) if chromosome[i] == 0
    ]
    target_x = 0
    target_y = 0
    #pylab.grid(True)

    for i, node in enumerate(chromosome):
        if node == 1:
            ax.plot([coords[i][0], 0], [coords[i][1], 0],
                    '--',
                    lw=.85,
                    color='red')
        if not node and nearest_supers[i] >= 0:
            ax.plot([coords[i][0], coords[nearest_supers[i]][0]],
                    [coords[i][1], coords[nearest_supers[i]][1]],
                    '-',
                    lw=.85,
                    color='blue')

    ax.plot(sensor_x, sensor_y, 'go', label=r'sensor')
    ax.plot(super_x, super_y, 'bo', label=r'super')
    ax.plot(target_x, target_y, 'ro', label=r'target')
    #add_ranges(ax, chromosome)
    #draw_clusters(ax, chromosome, nearest_supers)
    pylab.xticks(pylab.arange(0, FIELD_WIDTH + 1, 1), color='white')
    pylab.yticks(pylab.arange(0, FIELD_HEIGHT + 1, 1), color='white')
    #ax.set_xticklabels([])
    #ax.set_yticklabels([])
    #pylab.title(graph_title)
    pylab.xlim((-1, FIELD_WIDTH + 1))
    pylab.ylim((-1, FIELD_HEIGHT + 1))
    ax.set_aspect(1)

    #legend(loc='right', bbox_to_anchor=(2,1))
    #box = ax.get_position()
    #ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    #ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))

    #box = ax.get_position()
    #ax.set_position([box.x0, box.y0 + box.height * 0.1,
    #                 box.width, box.height * 0.9])
    #ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05),
    #      fancybox=True, shadow=True, ncol=5,numpoints=1)

    #LEGEND
    #box = ax.get_position()
    #ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    #ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), numpoints=1)

    filename = "/home/milleraj/Desktop/genetic_graphs/chrom%d.pdf" % n
    print filename
    pylab.savefig(filename)
예제 #9
0
def generate_graph(chromosome, nearest_supers, FIELD_WIDTH, FIELD_HEIGHT, 
                   graph_title, n):
    chromosome = [ int(i) for i in chromosome ]
    w = (FIELD_WIDTH)/4.0
    h = (FIELD_HEIGHT)/4.0
    fig = pylab.figure(figsize=(w+1,h))
    #fig = pylab.figure(figsize=(2.5,3))
    #ax = pylab.subplot(111)
    ax = Subplot(fig, 111)
    fig.add_subplot(ax)

    #ax.axis["right"].set_visible(False)
    #ax.axis["top"].set_visible(False)
    #ax.axis["bottom"].set_visible(False)
    #ax.axis["left"].set_visible(False)

    super_x = [ coords[i][0] for i in range(len(chromosome)) 
                if (chromosome[i] == 1) ]
    super_y = [ coords[i][1] for i in range(len(chromosome)) 
                if chromosome[i] == 1 ]
    sensor_x = [ coords[i][0] for i in range(len(chromosome)) 
                 if chromosome[i] == 0 ]
    sensor_y = [ coords[i][1] for i in range(len(chromosome)) 
                 if chromosome[i] == 0 ]
    target_x = 0
    target_y = 0
    #pylab.grid(True)

    for i, node in enumerate(chromosome):
        if node == 1:
            ax.plot([coords[i][0], 0], [coords[i][1], 0], '--',lw=.85, 
                    color='red')
        if not node and nearest_supers[i] >= 0:
            ax.plot([coords[i][0], 
                     coords[nearest_supers[i]][0]],
                    [coords[i][1], 
                     coords[nearest_supers[i]][1]],
                    '-', lw=.85, color='blue')

    ax.plot(sensor_x, sensor_y, 'go', label=r'sensor')
    ax.plot(super_x, super_y, 'bo', label=r'super')
    ax.plot(target_x, target_y, 'ro', label=r'target')
    #add_ranges(ax, chromosome)
    #draw_clusters(ax, chromosome, nearest_supers)
    pylab.xticks(pylab.arange(0, FIELD_WIDTH+1, 1), color='white')
    pylab.yticks(pylab.arange(0, FIELD_HEIGHT+1, 1), color='white')
    #ax.set_xticklabels([])
    #ax.set_yticklabels([])
    #pylab.title(graph_title)
    pylab.xlim((-1, FIELD_WIDTH+1))
    pylab.ylim((-1, FIELD_HEIGHT+1))
    ax.set_aspect(1)

    #legend(loc='right', bbox_to_anchor=(2,1))
    #box = ax.get_position()
    #ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    #ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))

    #box = ax.get_position()
    #ax.set_position([box.x0, box.y0 + box.height * 0.1,
    #                 box.width, box.height * 0.9])
    #ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05),
    #      fancybox=True, shadow=True, ncol=5,numpoints=1)

    #LEGEND
    #box = ax.get_position()
    #ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    #ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), numpoints=1)

    filename = "/home/milleraj/Desktop/genetic_graphs/chrom%d.pdf" % n
    print filename 
    pylab.savefig(filename)