示例#1
0
        if loc in spines:

            spine.set_position(('outward',10)) # outward by 10 points

            spine.set_smart_bounds(True)

        else:
示例#2
0


    if 'left' in spines:

        ax.yaxis.set_ticks_position('left')

        ax.yaxis.set_ticks(ticks)

    else:

        ax.yaxis.set_ticks([])



    if 'bottom' in spines:

        ax.xaxis.set_ticks_position('bottom')

        ax.xaxis.set_ticks(ticks)



    else:
示例#3
0
        subplot.scatter(

            positions[...,0].value_in(nbody_system.length),

            positions[...,1].value_in(nbody_system.length),

            s = 1,

            edgecolors = 'red',

            facecolors = 'red'

        )



        subplot.set_xlim(-4.0,4.0)

        subplot.set_ylim(-4.0,4.0)

        subplot.set_aspect(1.)



        title = 'time = {0:.2f}'.format(time.value_in(nbody_system.time))



        subplot.set_title(title)#, fontsize=12)

        spines = []

        if index % plot_matrix_size == 0:

            spines.append('left')



        if index >= ((number_of_rows - 1)*plot_matrix_size):

            spines.append('bottom')





        adjust_spines(subplot, spines,np.arange(-4.0,4.1, 1.0))



        if index % plot_matrix_size == 0:

            subplot.set_ylabel('y')



        if index >= ((number_of_rows - 1)*plot_matrix_size):

            subplot.set_xlabel('x')

            

    plt.savefig('simple_cluster_powerlaw.png', clobber=True)





def write_init_file(m, pos, vel, fname):

    """

    Writes the initial masses, positions, and velocities of a cluster to a file.

    """

    f = open(fname, 'w')



    for i in np.arange(np.size(m)):

        f.write(str(m[i]) + '\t' + str(pos[i,0]) + '\t' + str(pos[i,1]) + '\t' + str(pos[i,2]) + '\t' + str(vel[i,0]) + '\t' + '\t' + str(vel[i,1]) + '\t' + str(vel[i,2]) + '\n')