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


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?

  • $\begingroup$ Does your problem of setting the DataRange for ListPlot have anything to do with ExcelLink? If no, please modify your question and title accordingly. $\endgroup$ Apr 14, 2013 at 10:57

2 Answers 2


If the points were regularly spaced you could use Datarange:

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

enter image description here

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}}]]

enter image description here

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).

  • $\begingroup$ 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. $\endgroup$
    – Ghersic
    Apr 13, 2013 at 20:32
  • $\begingroup$ @Ghersic See update $\endgroup$ Apr 13, 2013 at 20:37
  • $\begingroup$ @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. $\endgroup$ Apr 13, 2013 at 20:41
  • 1
    $\begingroup$ @Ghersic It turns the separate y and t lists into a list of y,t pairs. $\endgroup$ Apr 13, 2013 at 21:57
  • 1
    $\begingroup$ If you don't like the linear algebraic Transpose, you can do the same thing with Thread, for instance: Thread[{{300, 600, 1200, 1440}, {28, 32, 37, 66}}] $\endgroup$
    – bill s
    Apr 24, 2013 at 6:44

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 } ];

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

Graph for the time series

This is equivalent to having tuples:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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