# Plot the Yearly Path of the Sun

Find the daily path of the Sun on the summer and winter solstices and the spring equinox, and the points of the complete analemma.

 In:= Xsummerpath = SunPosition[ DateRange[DateObject[{2014, 6, 21, 5, 0}], DateObject[{2014, 6, 21, 20, 0}], {10, "Minute"}]]; winterpath = SunPosition[ DateRange[DateObject[{2014, 12, 21, 5, 0}], DateObject[{2014, 12, 21, 20, 0}], {10, "Minute"}]]; equinoxpath = SunPosition[ DateRange[DateObject[{2014, 3, 20, 5, 0}], DateObject[{2014, 3, 20, 20, 0}], {10, "Minute"}]]; analemmaPoints = Map[QuantityMagnitude, SunPosition[ DateRange[DateObject[{2014, 1, 1, 9, 0}], DateObject[{2014, 12, 31, 9, 0}], 10]]["Values"], {2}];

Define some colors for styling.

 In:= XskyTopColor = RGBColor[0.27, 0.2, 0.75]; skyBottomColor = RGBColor[ 0.25, 0.43, 0.82]; groundColor = RGBColor[0.1, 0.1, 0.1]; sunColor = RGBColor[ 0.8588235294117647, 0.788235294117647, 0.5411764705882353];

Select some specific positions of the Sun at certain dates of interest.

 In:= XdisksOfSpecialInterest = Disk[QuantityMagnitude /@ #, 1] & /@ { summerpath[DateObject[{2014, 6, 21, 9, 0}]], winterpath[DateObject[{2014, 12, 21, 9, 0}]], equinoxpath[DateObject[{2014, 3, 20, 9, 0}]], SunPosition[DateObject[{2014, 9, 22, 9, 0}]]};

Create lines showing the daily path of the Sun on the solstices and equinox.

 In:= XlinesOfSpecialInterest = Line[Map[QuantityMagnitude, #, {2}]] & /@ {summerpath["Values"], winterpath["Values"], equinoxpath["Values"]};

Create annotations to label several features.

 In:= Xlabels = {sunColor, Rotate[Text["summer solstice", {86, 42}], 45 Degree], Rotate[Text[DateString[{2014, 6, 21}, {"DayShort", " ", "MonthNameShort", " ", "Year"}], {88, 40}], 45 Degree], Rotate[Text["equinox", {120, 28}], 40 Degree], Rotate[Text["winter solstice", {130, 5}], 45 Degree], Rotate[Text[DateString[{2014, 12, 21}, {"DayShort", " ", "MonthNameShort", " ", "Year"}], {133, 4}], 45 Degree], Rotate[Text[DateString[{2014, 9, 22, 9, 0}, {"DayShort", " ", "MonthNameShort", " ", "Year"}], {116.5, 30.5}], 41 Degree], Rotate[Text[DateString[{2014, 3, 20, 9, 0}, {"DayShort", " ", "MonthNameShort", " ", "Year"}], {104, 19}], 46 Degree]};

Make an image that shows the yearly path of the Sun at your location.

 In:= XSunPlot[] := Block[{xMin, xMax, yMin, yMax}, {{xMin, xMax}, {yMin, yMax}} = ({Min[#], Max[#]} + 10 {-1, 1}) & /@ Transpose[analemmaPoints]; Graphics[{Blue, Polygon[ {{xMin, yMin}, {xMin, yMax}, {xMax, yMax}, {xMax, yMin}}, VertexColors -> {skyBottomColor, skyTopColor, skyTopColor, skyBottomColor}], {sunColor, Disk[#, .5] & /@ analemmaPoints, EdgeForm[Red], disksOfSpecialInterest}, {sunColor, Opacity[.5], linesOfSpecialInterest}, {groundColor, Rectangle[{xMin, yMin}, {xMax, 0}]}, labels}, Frame -> True, FrameLabel -> {"azimuth", "altitude"}, PlotRange -> {{xMin, xMax}, {yMin, yMax}}, PlotRangeClipping -> True, PlotLabel -> "Yearly path of the Sun at 9:00 in " <> CommonName[First[GeoIdentify["City", \$GeoLocation]]]] ]
 In:= XSunPlot[]
 Out= ## Mathematica

Questions? Comments? Contact a Wolfram expert »