# Graphing time-series

I'm currently trying to use data gathered as a function of time (here, the fluorescence of a biological sample), but am new to Mathematica and don't know how to properly specify axis relations (and units, etc.).

Using ExcelLink 3.5, I've imported the data for one of many drugs whose effect on the fluorescence function I want to analyze. Because of how the information was imported, the listed data I've collected for $f(t)$ is in a list, with no reference to what the independent variable (x-axis) values should be. I made my plot with

ListPlot[{28,32,37,66}]


producing x-axis values of {1, 2, 3, 4} by default, and not t in minutes, which would be {300, 600, 1200, 1440} in my case).

How can I make a plot with the proper x-axis values?

• Does your problem of setting the DataRange for ListPlot have anything to do with ExcelLink? If no, please modify your question and title accordingly. – István Zachar Apr 14 '13 at 10:57

If the points were regularly spaced you could use Datarange:

ListPlot[{28, 32, 37, 66}, DataRange -> {300, 1440}]


However, they aren't spaced regularly, so in one way or another you have to specify the x values. Like this, for instance:

ListPlot[Transpose[{{300, 600, 1200, 1440}, {28, 32, 37, 66}}]]


BTW ExcelLink is not really necessary to get data from Excel. Mathematica's Import function can import data in various Excel compatible formats (XLS, XLSX, CSV, TSV).

• That looks useful, however, I need to graph it so that those four data points within ListPlot occur specifically at times {300,600,1200,1440}. I will certainly look through the documentation on DataRange, though! Thank you. I read about that prior to learning of ExcelLink. Do you know of an efficient way to import Excel data that will incorporate the data for both f(t) and t itself? I'm not particular to ExcelLink, I just assumed it was the easiest route. – Ghersic Apr 13 '13 at 20:32
• @Ghersic See update – Sjoerd C. de Vries Apr 13 '13 at 20:37
• @Ghersic Your question seemed to imply that you only had access to the y-values. If the t values are on the same sheet you can do a simple Import (type XLS or XLSX in the doc center search bar) and get the columns that contain the data from the result using the usual list manipulating functions. – Sjoerd C. de Vries Apr 13 '13 at 20:41
• Thanks. I do have access to both the y- and t-data. I will try doing this using Import command, extracting the lists from the rows, and inputting the ListPlot command in the format you laid out in your original answer. This does sound simpler than using ExcelLink. – Ghersic Apr 13 '13 at 20:46
• @Ghersic It turns the separate y and t lists into a list of y,t pairs. – Sjoerd C. de Vries Apr 13 '13 at 21:57

## Using Mathematica's Time-Series framework

If you have imported or entered data as tuples (e.g. $\Big\{(time_1,value_1), (time_2,value_2), \ldots \Big\}$ or as a list of values $\textbf{vals}$ with the corresponding list of times $\textbf{times}$ then the most natural thing to do since Version 10 is to use the Time Series - framework which has made representing TemporalData quite nice and easy.

So in your case you would have:

vals = { 28, 32, 37, 66 };
times = {300, 600, 1200, 1440};

data = EventSeries[ vals, { times } ];

ListPlost @ data (* or more cumbersome data[ "Path" ] // ListPlot *)


This is equivalent to having tuples:

tuples = Transpose @ { times, vals };
EventSeries @ tuples // ListPlot