1
$\begingroup$

Please suggest how to plot $ \sin\theta $ in degree. I am trying using the given below code but it is not working (It works if used Ticks without Frame -> True).

Plot[{Sin[θ°]}, {θ, 0, 360}, Frame -> True, 
      PlotStyle -> {Red, Thickness[.009]}, 
      FrameTicks -> {{Automatic, Automatic}, {Range[0, 360, 45], 
      Automatic}}, FillingStyle -> LightBlue, Filling -> Bottom]

enter image description here

$\endgroup$
4
  • $\begingroup$ What is not working? $\endgroup$
    – user69708
    Feb 16, 2020 at 23:14
  • $\begingroup$ Calculation from standard convention into degrees is trivial, just multiply an angle (in radians) by 180/Pi to get degrees. There is a question related to plotting sinus (in radians) in complexes Plotting complex Sine $\endgroup$
    – Artes
    Feb 16, 2020 at 23:14
  • 1
    $\begingroup$ The code works fine in Mathematica 12. In Mathematica, Degree is a constant equal to Pi/180. $\endgroup$ Feb 16, 2020 at 23:28
  • $\begingroup$ All you need is a space between θ and ° $\endgroup$
    – m_goldberg
    Feb 17, 2020 at 6:30

1 Answer 1

2
$\begingroup$

One way to introduce units on the horizontal axis would be to define

ticks = Thread[{Range[0, 360, 45], 
   Quantity[Range[0, 360, 45], "°"]}];

And then plot with

Plot[{Sin[θ °]}, {θ, 0, 360}, Frame -> True, 
 PlotStyle -> {Red, Thickness[.009]}, 
 FrameTicks -> {{Automatic, Automatic}, {ticks, Automatic}}, 
 FillingStyle -> LightBlue, Filling -> Bottom]

enter image description here

A simple way to vary the filling color is with Lighter and Darker. For example, FillingStyle -> Lighter[Blue, 3/10] makes the filling color about 30% lighter than Blue alone.

Another way is with FillingStyle -> Directive[Opacity[7/10],Blue]. This also makes the filling color about 30% lighter than Blue alone. Directive has many useful options and can be applied in many ways.

The Mathematica documentation describes many other ways to specify colors. Another example is use FillingStyle -> Hue[0.6, 0.2]. The 0.6 value makes it blue. Lower or raise the second value to get a lighter or darker blue.

$\endgroup$
1
  • $\begingroup$ ,Thanks, It is working.Can you also suggest that how to vary opacity of filling style. Please use blue instead of LightBlue. $\endgroup$ Feb 17, 2020 at 0:14

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