Skip to content

Instantly share code, notes, and snippets.

@ericabell
Created November 14, 2014 21:34
Show Gist options
  • Save ericabell/6186ba9a1f6ed99cbaaf to your computer and use it in GitHub Desktop.
Save ericabell/6186ba9a1f6ed99cbaaf to your computer and use it in GitHub Desktop.
plot sin and cos from 0 to 360 degrees with nice tick labels
x = var('x')
f(x) = sin((x*pi)/180)
g(x) = cos((x*pi)/180)
p1 = plot([f,g],
(x,0,360),
ticks=[[30,45,60,90,120,135,150,180,270,360],
[-1,
-sqrt(3)/2,
-sqrt(2)/2,
-1/2,1/2,
sqrt(2)/2,
sqrt(3)/2,
1]
],
tick_formatter=[["$30^\circ$", "$45^\circ$", "$60^\circ$", "$90^\circ$",
"$120^\circ$", "$135^\circ$", "$150^\circ$","$180^\circ$",
"$270^\circ$","$360^\circ$"],
["$-1$",
"$-\\frac{\\sqrt{3}}{2}$",
"$-\\frac{\\sqrt{2}}{2}$",
"$-\\frac{1}{2}$",
"$\\frac{1}{2}$",
"$\\frac{\\sqrt{2}}{2}$",
"$\\frac{\\sqrt{3}}{2}$",
"$1$"]
]
) + plot([-sqrt(3)/2,-sqrt(2)/2,-1/2,1/2,sqrt(2)/2,sqrt(3)/2,1,-1],(x,0,360),linestyle='dotted')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment