Mathematica Mathematica: Regarding ListPlot and Manipulate

  • Thread starter Thread starter Kortirion
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion revolves around issues faced when using ListPlot with Manipulate in Mathematica to visualize functions dependent on a parameter t. The user initially struggles to plot one specific function alongside others, as it returns a blank output despite working individually. Suggestions include using Plot instead of ListPlot and testing the function with fixed values to identify the problem. The user later resolves the issue by employing the Block command within Manipulate, allowing for proper visualization of the desired function values. This solution effectively treats the function correctly, achieving the intended graphical representation.
Kortirion
Messages
8
Reaction score
0
I am having trouble with ListPlot in combination with Manipulate. I can't see why it doesn't do what I tell it to.

What I'm trying to do: I have several functions that is dependent upon one parameter t. These functions I got from solving a system with DSolve. I'd like to see their values varying with this parameter t next to each other like amplitude spikes, spaced 1 apart on an axis (not the t axis!).

What I did: I tried using the Manipulate command like this

Manipulate[ListPlot[{
0.02 t^2,
0.4 t,
Abs[Subscript[y, 5][t] /. solution[[1]]]^2,
0.4 t,
0.02 t^2},
Filling -> filling, PlotRange -> All], {t, 0, 25}, {filling, {None, Axis, Top, Bottom}}]

here on place 3 is one of the functions that I'd like to see varying with t, and the other four places is just filled with some "whatever" functions.

What I get: I get the anticipated evolution of all those "whatever" functions, although nothing for the one in the middle at place 3. This is strange to me! Since I can successfully plot the function alone in t like this

Plot[Abs[Subscript[y, 5][t] /. solution[[1]]]^2, {t, 0, 75}]

But in the above Manipulate and ListPlot I have a total blank on place 3.


Someone feeling handy today?
 
Physics news on Phys.org
This is a wild guess here.

I'm thinking you believe ListPlot means plot this list of functions.

I believe Mathematica thinks ListPlot means plot this list of data points.
http://reference.wolfram.com/mathematica/ref/ListPlot.html?q=ListPlot&lang=en
I do not believe ListPlot creates lists of points for you.

Perhaps try
Manipulate[Plot[{
0.02 t^2,...

and see what you get.
Plot[{a list of functions}
should plot that list of functions on top of each other.

OR

Temporarily throw away your Manipulate and just see what

ListPlot[{
0.02 t^2,...

does for a specific value of t. If that doesn't work then you have narrowed down your problem.
 
Hello and thanks for the reply.
I know what ListPlot does in that sense, however I thought it was worth a try since it did work to visualize an explicit functions amplitude like I wanted. Only now it failed with using something I've got as a solution. Bleh.

I've changed some stuff now to accommodate nonliterary in my system, so it's NDSolve now. From this I receive nice solutions, but I'd still like to visualize them simultaneously spaced equally on a line. These will look like dots moving up and down as I vary the parameter t on each "site". Get the picture?
I'm no pro at Mathematica, so do you know of any way to realize this? As I looked at it the Manipulate function and it looks like the best bet as I'd like to be able to vary t forth and back.
 
I'm sorry, but I don't get the picture.

Are you possibly trying to accomplish something like

Manipulate[
GraphicsRow[{
Plot[someCompletePlotDependingOnt],
Plot[someOtherCompletePlotDependingOnt],
Plot[yetAnotherCompletePlotDependingOnt],
Plot[etcCompletePlotDependingOnt]
}],
restOfMainpulateArgumentsIncludingt
]

http://reference.wolfram.com/mathematica/ref/GraphicsRow.html
 
Last edited:
Hey again. And no, that's not quite what I'd like. And ok, if you don't get my picture just run this and see

Manipulate[
ListPlot[{0.02 t^2, 0.4 t, 17 Sin[t], 0.4 t, 0.02 t^2},
PlotRange -> 30, Filling -> filling], {t, 0,
35}, {filling, {None, Axis, Bottom, Top}}]

It views the plot as one-dimensional, having those dots racing up and down. Maybe there's some better option to this than using ListPlot and the rest, but I don't know of any.. Thank you for your time trying to help, much appreciated.
 
Hello. Just reporting in that I solved this issue by using the "Block" command

Manipulate[
ListLinePlot[
Table[Block[{t = k}, Abs[Subscript[y, i][t] /. solution[[1]]]^2], {i, 50, 151}],
PlotRange -> {0, 0.7}, Filling -> Axis], {k, 0, 1100}]

With this it, as I wanted, actually took forth the value of my solution and did not treat it as an "object".
 

Similar threads

Replies
5
Views
2K
Replies
2
Views
1K
Replies
18
Views
4K
Replies
1
Views
2K
Replies
3
Views
2K
Replies
1
Views
2K
Replies
10
Views
2K
Replies
1
Views
6K
Back
Top