# ListPlot is not plotting functions from DSolve, brought by ReplaceAll(/.) command

I have the following simple differential equation

ODE = DSolve[{x'[t] == 1, x == 1}, x[t], t]


and I'd like to visualize how the solution x[t] behaves over time in space (which is just along the x-axis), so I tried the following

Manipulate[ListPlot[{{x[t] /. ODE, 0}},PlotRange->{{0,10},{-1,1}}], {t, 0, 10}]


but this gives blank output. Oddly the simple Plot command outputs expected result. I assume that the nature of these two commands is inherently different, or Manipulate is screwing something here. What would be the reason/would there be any word-around?

The problem here is the way the replacements are made. ODE is a replacement rule that looks like:

{{x[t] -> 1 + t}}


The Manipulate effectively tries to evaluate something like the following (for some value of t you selected):

DynamicModule[{t = 10}, ListPlot[{{x[t] /. ODE, 0}}]]


The problem here is that during the evaluation, x[t] first gets evaluated to x and then the replacement rule x[t] -> 1 + t doesn't match x any more.

You can fix this in two ways. The first way is to use this definition of ODE instead:

ODE = First @ DSolve[{x'[t] == 1, x == 1}, x, t]
Manipulate[ListPlot[{{x[t] /. ODE, 0}}, PlotRange -> {{0,10},{-1,1}}], {t, 0, 10}]


{x -> Function[{t}, 1 + t]}

This works because the replacement rule now specifies that x is a function, rather than that x[t] is a symbolic expression.

The second (and in my opinion the superior) way is to use DSolveValue instead so you don't have to muck about with replacement rules at all:

ODE = DSolveValue[{x'[t] == 1, x == 1}, x, t]
Manipulate[ListPlot[{{ODE[t], 0}}, PlotRange -> {{0,10},{-1,1}}], {t, 0, 30}]


Function[{t}, 1 + t]

# Edit

You also remarked that Plot does work. This is because Plot uses Block to assign a value to t and in that case the value of t in x[t] and in ODE matches again. Compare:

Block[{t = 10}, x[t] /. ODE]
Module[{t = 10}, x[t] /. ODE]

• This clarified the problem I was having and solved the issue. – user28936 Nov 16 at 15:02

I am not sure this is what you want but...

ODE = DSolve[{x'[t] == 1, x == 1}, x[t], t]

Manipulate[
Plot[x[t] /. ODE // Evaluate, {t, 0, T},
PlotRange -> {{0, 5}, {0, 5}}], {T, 1, 5}] • Yeah, Plot works fine. But ListPlot doesn't work correctly with Manipulate. I want to see how the coordinate of x[t] moves in space over time. So my first approach was to plot the coordinate {x[t],0} along the x-axis and manipulate/animate time, which doesn't seem to work so simply. – user28936 Nov 16 at 14:46