# Mathematica Q&A: Plotting Trig Functions in Degrees

March 31, 2011 — Andrew Moylan, Technical Communication & Strategy

Got a question about Mathematica? The Wolfram Blog has answers! We’ll regularly answer selected questions from users around the web. You can submit your question directly to the Q&A Team using this form.

This week’s question comes from Brian, who is a part-time math teacher:

How do you plot trigonometric functions in degrees instead of radians?

Trigonometric functions in Mathematica such as Sin[x] and Cos[x] take x to be given in radians:

To convert from degrees to radians, multiply by π ⁄ 180. This special constant is called Degree in Mathematica.

The symbol ° is a handy shorthand for Degree and is entered as Esc-d-e-g-Esc. You can also find this symbol in the Basic Math Assistant palette in the Palettes menu of Mathematica.

Using either Degree or °, you can plot trigonometric functions in degrees:

That answers the main question, but here’s a related hint.

When plotting trigonometric functions in degrees, you might also want to manually specify exactly where Mathematica draws tick marks. You can do this using the Ticks option:

(Here, Range[0, 360, 45] specifies the tick marks on the x axis, and Automatic uses the default tick marks on the y axis.)

The Ticks option is very flexible. You can specify where tick marks are drawn, what labels they should have, how long they are, and even colors and styles.

Download the Computable Document Format (CDF) file for this post to see how to get the custom tick marks used in this plot:

If you have a question you’d like to see answered in this blog, you can submit it to the Q&A Team using this form.

Download the CDF file

Posted in: Mathematica Q&A

### 8 Comments

 Wouldn’t it be more logical to write it as Sin[theta] and theta is from 0° to 360°? In that case, the axis would still be labeled in radians, right? ;-) Of course, Ticks fix all that, but the notation of the code is not necessarily the most natural one. Posted by Luboš Motl    March 31, 2011 at 1:57 pm
 If I understand it right, Plot[ SIn[theta], {theta,0,360} ] plots with major ticks at multiples of decades or something – still in degrees, not radians. Good post. thanks. Posted by Isaac Abraham    March 31, 2011 at 5:17 pm
 This tip helped me a lot, thanks. Posted by Pedro Vagner    March 31, 2011 at 6:21 pm
 good article.. i’ve also try to write it in Pi based in your code… ========================== majorticks = Table[{\[Theta], Row[{\[Theta]}]}, {\[Theta], 0, 2 Pi, 1/3 Pi}]; minorticks = Table[{\[Theta], Spacer[{0, 0}], {0.005, 0}}, {\[Theta], 0, 2 Pi, 1/8 Pi}]; Plot[Sin[\[Theta]], {\[Theta], 0, 2 Pi}, Ticks -> {Join[majorticks, minorticks]}] ======================== Posted by Aji Raditya    March 31, 2011 at 9:33 pm
 Be careful though: Working in degrees, the derivative of sine is not cosine. Posted by Stan Wagon    April 1, 2011 at 5:15 pm
 This is another possibility. :-) Plot[{Sin[theta ], Cos[theta]}, {theta, 0 Degree, 360 Degree}, Ticks -> {Range[0 Degree, 360 Degree, 45 Degree]}] Posted by Dawid Dworzak    April 10, 2011 at 2:20 am
 Dear Sir, Thank you kindly for a reply. I met an Oxford student last night and he wrote quite a script. I found your solution is fine.Thanks to the other bloggers too. Brian Posted by Brian McCallum    July 12, 2011 at 8:10 am
 Merci, je n’y avait même pas pensé. exquis ! Posted by en cliquant ici    January 21, 2015 at 12:52 am

Leave a comment

Loading...

Or continue as a guest (your comment will be held for moderation):

Wolfram

BROWSE BY TOPIC