Advertisement
vvsvvs

Untitled

May 14th, 2022
780
167 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def plot_vectors(vectors, colors):
  2.     """
  3.    Plots vectors on the xy-plane. The `vectors` parameter is a Python list.
  4.    Each vector is specified in the format [start_x, start_y, end_x, end_y]
  5.    """
  6.    
  7.     start_point_x = [vector[0] for vector in vectors]
  8.     start_point_y = [vector[1] for vector in vectors]
  9.     direction_x = [vector[2] - vector[0] for vector in vectors]
  10.     direction_y = [vector[3] - vector[1] for vector in vectors]
  11.  
  12.     plt.quiver(start_point_x, start_point_y, direction_x, direction_y, scale_units="xy", angles="xy", scale=1, color=colors)
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement