2
$\begingroup$

Considering I have weather data for last 10 years for London, how can I make a scatter plot that will show the previous day's temperature as a function from today's temperature?

$\endgroup$
7
$\begingroup$

You can Partition the data into pairs of successive values. Reverse the data to make the previous day the dependent variable. Examples:

Partition[{1, 2, 3, 4, 5}, 2, 1]
(* {{1, 2}, {2, 3}, {3, 4}, {4, 5}} *)

Partition[Reverse@{1, 2, 3, 4, 5}, 2, 1]
(* {{5, 4}, {4, 3}, {3, 2}, {2, 1}} *)

Reverse /@ Partition[{1, 2, 3, 4, 5}, 2, 1]
(* {{2, 1}, {3, 2}, {4, 3}, {5, 4}} *)

Mathematica's weather data. ListPlot will plot the points.

data = WeatherData["London", "Temperature", {{2004, 1, 1}, {2013, 12, 31}, "Day"}];

ListPlot@Partition[Reverse@data["Values"], 2, 1]

Mathematica graphics

$\endgroup$

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.