Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can I use "MinTemperature", "MaxTemperature", and "Temperature" properties of WeatherData for one or more cities in one line of code?

share|improve this question
3  
What's the point of one line of code? Do you intend anything more complex than, say, this variant of an example from the help page? DateListPlot[WeatherData["KABQ", #, {2008, 3}], Joined -> True] & /@ {"Pressure", "Temperature", "WindSpeed"} // TableForm –  whuber Nov 15 '12 at 6:00
3  
"one line of code" is overrated. –  rm -rf Nov 15 '12 at 6:08
    
Thanks for guidance –  Soum Nov 15 '12 at 7:40
    
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2)Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign` –  chris Nov 15 '12 at 8:04
    
@Soum: take a look at Map[] in the help files. –  A. Goossens Nov 15 '12 at 11:22
add comment

1 Answer 1

Here's something you could build on. It only shows min and max temperatures. The DateListPlot function layout is fairly simple for easy editing.

londoncoordinates = CityData["London", "Coordinates"];
londonweatherstation = WeatherData[londoncoordinates, "NearestStation"];
sydneycoordinates = CityData["Sydney", "Coordinates"];
sydneyweatherstation = WeatherData[sydneycoordinates, "NearestStation"];

DateListPlot[{
  WeatherData[londonweatherstation, 
   "MaxTemperature", {{2011, 1, 2}, {2012, 1, 2}, "Day"}], 
  WeatherData[londonweatherstation, 
   "MinTemperature", {{2011, 1, 2}, {2012, 1, 2}, "Day"}],
  WeatherData[sydneyweatherstation, 
   "MaxTemperature", {{2011, 1, 2}, {2012, 1, 2}, "Day"}], 
  WeatherData[sydneyweatherstation, 
   "MinTemperature", {{2011, 1, 2}, {2012, 1, 2}, "Day"}]},
  Joined -> True, 
 PlotStyle -> {Hue[0.9, 0.6, 0.6], Hue[0.67, 0.6, 0.6], 
   Hue[0.9, 0.6, 0.6], Hue[0.67, 0.6, 0.6]}, 
 Filling -> {{1 -> {{2}, Lighter[Pink]}}, {3 -> {{4}, Green}}},
 AspectRatio -> 0.5, ImageSize -> 600, 
 FrameTicks -> {{Automatic, Automatic},
   {{"Jan 2011", "Mar 2011", "May 2011", "Jul 2011", "Sep 2011", 
     "Nov 2011", "Jan 2012"}, Automatic}},
 DateTicksFormat -> {"MonthNameShort"},
 FrameLabel -> {{Style["\[Degree]C", Bold, Medium], Null}, {Null, 
    Null}}, RotateLabel -> False,
 PlotLabel -> Row[{Style["Sydney", 22, Bold, Green]
    , "                   ", 
    Style["London", 22, Bold, Lighter[Pink]]}]]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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