*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.

## 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.

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.

This tip helped me a lot, thanks.

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]}]

========================

Be careful though: Working in degrees, the derivative of sine is not cosine.

This is another possibility. :-)

Plot[{Sin[theta ], Cos[theta]}, {theta, 0 Degree, 360 Degree},

Ticks -> {Range[0 Degree, 360 Degree, 45 Degree]}]

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

Merci, je n’y avait même pas pensé. exquis !