4
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – William Briand Mar 13 '14 at 20:00
  • $\begingroup$ not about Degree but duplicate imo. Also related $\endgroup$ – Kuba Mar 13 '14 at 20:46
4
$\begingroup$
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}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Interesting, I din't know about FindDivisions. +1 $\endgroup$ – Murta Mar 13 '14 at 20:25
  • 1
    $\begingroup$ @Murta The function doesn't work very well. The standard Plot[] automatic ticks are much more robust. $\endgroup$ – Dr. belisarius Mar 14 '14 at 0:27
  • $\begingroup$ Is there a way to keep the nice sub-ticks when replacing the tick labels? $\endgroup$ – Alexey Bobrick May 2 '16 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.