示例#1
0
    def create_artists(self, legend, orig_handle, xdescent, ydescent, width,
                       height, fontsize, trans):

        p = FancyArrowPatch(posA=(-xdescent - (width / 10),
                                  -ydescent + height / 2),
                            posB=(-xdescent + width + (width / 10),
                                  -ydescent + height / 2),
                            mutation_scale=height * 1.5)
        self.update_prop(p, orig_handle, legend)
        p.set_transform(trans)
        return [p]
示例#2
0
 def create_artists(self, legend, orig_handle, xdescent, ydescent, width,
                    height, fontsize, trans):
     xdata, xdata_marker = self.get_xdata(legend, xdescent, ydescent, width,
                                          height, fontsize)
     ydata = ((height - ydescent) / 2.) * np.ones(xdata.shape, float)
     legline = FancyArrowPatch(posA=(xdata[0], ydata[0]),
                               posB=(xdata[-1], ydata[-1]),
                               mutation_scale=self.ms,
                               **orig_handle.arrowprops)
     legline.set_transform(trans)
     return legline,
示例#3
0
    def create_photon_legend(self, legend, orig_handle, 
                       xdescent, ydescent, width, height, fontsize,
                       trans):
        
            xdata, ydata = get_photon_data2D(width, 0.8*height, 3, 100)
            ydata += height*0.3
            legline = Line2D(xdata, ydata)

            self.update_prop(legline, orig_handle, legend)
            legline.set_drawstyle('default')
            legline.set_marker("")
            
            legline.set_transform(trans)
            
            yar = FancyArrowPatch((xdata[3],ydata[0]), (xdata[3]+0.3*width, ydata[0]), 
                                  mutation_scale=10,
                                  lw=1, arrowstyle="-|>", color='y')
            yar.set_transform(trans)
            return [legline, yar]
def display_bicycle_wheels(rear_wheel, front_wheel, theta):               
    # Initialize figure
    fig = plt.figure(figsize=(5, 5))
    ax = plt.gca()
    ax.set_xlim([0,4])
    ax.set_ylim([0,4])
    ax.tick_params(axis='both', which='major', labelsize=7)
    plt.title('Overhead View')
    plt.xlabel('X (m)',weight='bold')
    plt.ylabel('Y (m)',weight='bold')

    ax.plot(0,0)
  
    rear_wheel_x = FancyArrowPatch((0,0), (0.4,0),
                                        mutation_scale=8,color='red')
    rear_wheel_y = FancyArrowPatch((0,0), (0,0.4),
                                        mutation_scale=8,color='red')

    front_wheel_x = FancyArrowPatch((0,0), (0.4,0),
                                        mutation_scale=8,color='blue') 
    front_wheel_y = FancyArrowPatch((0,0), (0,0.4),
                                        mutation_scale=8,color='blue')

    custom_lines = [Line2D([0], [0], color='red', lw=4),
                    Line2D([0], [0], color='blue', lw=4)]
    
    # Apply translation and rotation as specified by current robot state
    cos_theta, sin_theta = np.cos(theta), np.sin(theta)
    Tw_rear = np.eye(3)
    Tw_rear[0:2,2] = rear_wheel
    Tw_rear[0:2,0:2] = [[cos_theta,-sin_theta],[sin_theta,cos_theta]]
    Tw_rear_obj = transforms.Affine2D(Tw_rear)

    Tw_front = np.eye(3)
    Tw_front[0:2,2] = front_wheel
    Tw_front[0:2,0:2] = [[cos_theta,-sin_theta],[sin_theta,cos_theta]]
    Tw_front_obj = transforms.Affine2D(Tw_front)

    ax_trans = ax.transData
    
    rear_wheel_x.set_transform(Tw_rear_obj+ax_trans)
    rear_wheel_y.set_transform(rear_wheel_x.get_transform())
    ax.add_patch(rear_wheel_x)
    ax.add_patch(rear_wheel_y)

    front_wheel_x.set_transform(Tw_front_obj+ax_trans)
    front_wheel_y.set_transform(front_wheel_x.get_transform())
    ax.add_patch(front_wheel_x)
    ax.add_patch(front_wheel_y)

    ax.legend(custom_lines, ['Rear Wheel', 'Front Wheel'])