# How to change display of axis unit from radians to degrees in a plot

Is there a simple way, besides changing my function to use Degree as input, to display the x-axis in degrees in a plot of a function defined with its independent variable taking radians?

-
It does not get simpler than Plot[f[x Degree],{x,-1,1}] , and you can control exactly what is shown on the axis with the Ticks option of Plot. Theoretically you could do post-processing on the Graphic object but that seems to me to be overkill. –  William Briand Mar 13 at 20:00
–  Kuba Mar 13 at 20:46

f[range_List, divs_] := {# Pi/180, # Degree} & /@ FindDivisions[range 180/Pi, divs, 10];
plot[g_, range_]:= Plot[g[x], Evaluate@Join[{x}, range], Ticks-> {f[range, 10], Automatic}];
g = Sin;
plot[g, {0, 2 Pi}]


-
Interesting, I din't know about FindDivisions. +1 –  Murta Mar 13 at 20:25
@Murta The function doesn't work very well. The standard Plot[] automatic ticks are much more robust. –  belisarius Mar 14 at 0:27

Here is a slightly different way to do it. It has the advantage of accepting the options of Plot.

SetAttributes[degreePlot, HoldAll]
degreePlot[f_, range_, opts : OptionsPattern[Plot]] :=
Plot[f[x Degree], {x, range[[1]], range[[2]]},
Evaluate @ FilterRules[Join[{opts}, {Ticks -> range}], Options[Plot]]]
degreePlot[Sin, {0, 360, 10}, Frame -> True, PlotStyle -> Red]


-
Thanks Would you also tell me what does @ and @@ mean in mathematica, I see it all the time but cannot figure out what it means even after some googling..Thanks –  henry leung Mar 14 at 5:37
@henryleung. @ is the prefix form of for a function call; f @ x is essentially the same as f[x]. Similarly, f @@ h[x] is essentially the same as Apply[f, h[x]]. You can find more at Prefix and Apply –  m_goldberg Mar 14 at 10:53