Skip to content

Instantly share code, notes, and snippets.

@raghavrv
Created December 28, 2015 16:10
Show Gist options
  • Save raghavrv/11c4efe95d5f914237ab to your computer and use it in GitHub Desktop.
Save raghavrv/11c4efe95d5f914237ab to your computer and use it in GitHub Desktop.
%matplotlib inline
import matplotlib.pyplot as plt
from matplotlib.patches import Arc
from math import sqrt
fig = plt.figure()
ax = fig.add_subplot(111)
fig.set_size_inches(10, 5)
plt.arrow(0, 0, 1, 0, length_includes_head = True, head_width = 0.05, width=0.01, color="k")
ax.text(0.5, 0.05, "u", fontsize=25)
plt.arrow(0, 0, 0.5, 0.5*sqrt(3), length_includes_head = True, head_width = 0.05, width=0.005, color="k")
ax.text(0.20, 0.5, "v", fontsize=25)
plt.arrow(1, 0, -0.5, 0.5*sqrt(3), length_includes_head = True, head_width = 0.05, width=0.005, color="k")
plt.arrow(0, 0, -0.5, 0.5*sqrt(3), length_includes_head = True, head_width = 0.05, width=0.005, edgecolor="k", linestyle='--', facecolor="grey")
ax.text(0.79, 0.5, "w", fontsize=25)
ax.text(-0.42, 0.5, "w'", fontsize=25)
ax.add_patch(Arc((0, 0), 0.3, 0.3, 0, 0, 60, linestyle="--"))
ax.add_patch(Arc((0, 0), 0.8, 0.8, 0, 0, 120, linestyle='--'))
ax.text(0.18, 0.08, "60")
ax.text(0.35, 0.28, "120")
ax.spines['left'].set_position('center')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.spines['left'].set_smart_bounds(True)
ax.spines['bottom'].set_smart_bounds(True)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.set_xlim(-1, 1)
ax.set_ylim(0, 1)
# Axes. The matplotlib axis is all screwed up
plt.arrow(0, 0, 0, 1, width=0.001, linestyle="--", edgecolor="g", facecolor="g")
plt.arrow(1, 0, -1.6, 0, width=0.001, linestyle="--", edgecolor="g", facecolor="g")
# Intercepts
plt.arrow(-0.6, 0.5*sqrt(3), 1.6, 0, width=0.001, linestyle="--", edgecolor="b", facecolor="b")
plt.arrow(1, 0, 0, 1, width=0.001, linestyle="--", edgecolor="b", facecolor="b")
# Im just skipping unicode/latex for pi to simplify life a bit
ax.text(-0.15, 0.78, "sin(pi/3)", fontsize=22)
plt.grid()
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment