for i in range(20): micro.grains.append(Grain(i + 1, eulers[i + 1])) micro.get_grain(i + 1).volume = grain_sizes[i] # build a custom pole figure pf = PoleFigure(microstructure=micro, hkl='001') #, lattice=Ti7Al) #pf.resize_markers = True pf.mksize = 100 pf.set_map_field('strain', grain_sizes, field_min_level=0.0, field_max_level=1000., lut='jet') fig = plt.figure(figsize=(8, 5)) ax1 = fig.add_axes([0.05, 0.05, 0.8, 0.9], aspect='equal') pf.plot_sst(ax=ax1, mk='o') ax1.set_title('%s-axis SST inverse %s projection' % (pf.axis, pf.proj)) # to add the color bar ax2 = fig.add_axes([0.85, 0.05, 0.05, 0.9]) norm = colors.Normalize(vmin=0., vmax=1000.) cb = colorbar.ColorbarBase(ax2, cmap=cm.jet, norm=norm, orientation='vertical') cb.set_label('Grain size (pixels)') image_name = os.path.splitext(__file__)[0] + '.png' print('writting %s' % image_name) plt.savefig(image_name, format='png') from matplotlib import image image.thumbnail(image_name, 'thumb_' + image_name, 0.2)
step = 1 # plot every step point max_step = data.shape[0] # create a microstructure with the initial grain orientation micro = Microstructure(name='1g', autodelete=True) g = Grain(50, Orientation.from_euler((12.293, 149.266, -167.068))) micro.add_grains([(12.293, 149.266, -167.068)], grain_ids=[50]) ipf = PoleFigure(proj='stereo', microstructure=micro) ipf.mksize = 100 ipf.set_map_field('grain_id') fig = plt.figure(1, figsize=(6, 5)) # for IPF ax1 = fig.add_subplot(111, aspect='equal') print('** plotting the initial orientation (with label for legend) **') ipf.plot_sst(ax=ax1, mk='.', col='k', ann=False) ax1.set_title('grain rotation in tension') axis = np.array([0, 0, 1]) grain = micro.get_grain(50) cgid = Microstructure.rand_cmap().colors[grain.id] # color by grain id g = grain.orientation_matrix() axis_rot_sst_prev = np.array(ipf.sst_symmetry_cubic(g.dot(axis))) print('** plotting ipf loading axis trajectory **') for k in range(0, max_step, step): rot = np.array([[R11[k], R12[k], R13[k]], [R21[k], R22[k], R23[k]], [R31[k], R32[k], R33[k]]]) # apply R^t to the initial orientation given by g new_g = rot.transpose().dot(g) axis_rot_sst = ipf.sst_symmetry_cubic(new_g.dot(axis)) ipf.plot_line_between_crystal_dir(axis_rot_sst_prev,