Code:

import matplotlib
import matplotlib.pyplot as plt
import matplotlib.collections as collections
import matplotlib.ticker as ticker
from math import sqrt, atan
fig = plt.figure()
ax = fig.add_subplot(111)
rect = matplotlib.patches.Rectangle((-4,-4), 8, 8, facecolor="blue", edgecolor="k", linewidth=4.0, alpha = 150)
ax.add_patch(rect)
ax.scatter([0],[0],color="k",s=200)
ax = plt.axes()
a=8
b=6
c=-3
d=-4
ax.arrow(0, 0, a, 0, head_width=1, head_length=1, width=0.2, length_includes_head=True, fc='c', ec='c', alpha=80)
ax.arrow(0, 0, 0, b, head_width=1, head_length=1, width=0.2, length_includes_head=True, fc='k', ec='k', alpha=80)
ax.arrow(0, 0, c, 0, head_width=1, head_length=1, width=0.2, length_includes_head=True, fc='r', ec='r', alpha=80)
ax.arrow(0, 0, 0, d, head_width=1, head_length=1, width=0.2, length_includes_head=True, fc='m', ec='m', alpha=80)
lista = [a,b,c,d]
lista = [ abs(i) for i in lista]
lista.sort()
lista.reverse()
lista
print lista
ax.arrow(0, 0, lista[0], lista[1], head_width=1, head_length=1, width=0.2, length_includes_head=True, fc='c', ec='c', alpha=80)
ax.annotate('TOP VIEW', xy=(-8, 8),
xycoords='axes points',
horizontalalignment='right', verticalalignment='bottom',
fontsize=20)
patches = []
plt.xlim([-10, 10])
plt.ylim([-10, 10])
p = collections.PatchCollection(patches)
ax.add_collection(p)
ax.xaxis.set_major_locator(ticker.MultipleLocator(20))
ax.yaxis.set_major_locator(ticker.MultipleLocator(20))
plt.show()

How can I solve this problem?
Tweet This+ 1 thisPost To Linkedin