Mathematica: Regarding ListPlot and Manipulate

  • Mathematica
  • Thread starter Kortirion
  • Start date
  • Tags
    Mathematica
In summary: So if t is changed the result is an actual plot that changes as well.In summary, I am having trouble with ListPlot in combination with Manipulate. I can't see why it doesn't do what I tell it to. I tried using the Manipulate command like thisManipulate[ListPlot[{0.02 t^2, 0.4 t, 17 Sin[t], 0.4 t, 0.02 t^2}, PlotRange -> 30, Filling -> filling], {t, 0, iets 35}, {filling, {None, Axis, Bottom, Top}}]but I get the anticipated evolution of all those "whatever"
  • #1
Kortirion
8
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
  • #2
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.
 
  • #3
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.
 
  • #4
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:
  • #5
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.
 
  • #6
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".
 

FAQ: Mathematica: Regarding ListPlot and Manipulate

How do I plot a list of data points in Mathematica using ListPlot?

To plot a list of data points in Mathematica, you can use the ListPlot function. This function takes in a list of data points in the form of {{x1,y1}, {x2,y2}, ...} and plots them as points on a graph. You can also customize the appearance of the plot by specifying options such as the color and style of the points.

Can I add labels and axes to my ListPlot in Mathematica?

Yes, you can add labels and axes to your ListPlot in Mathematica by using the FrameLabel and AxesLabel options. These options allow you to specify the labels for the x and y axes, as well as the overall frame label. You can also customize the appearance of the labels by specifying options such as font size and style.

How do I manipulate my ListPlot in Mathematica using the Manipulate function?

The Manipulate function in Mathematica allows you to interactively manipulate your plot by changing the values of certain variables. To use this function, you can wrap your ListPlot code inside Manipulate, and specify the variables you want to manipulate. This will create a dynamic plot that updates as you change the values of the variables.

Can I add a legend to my ListPlot in Mathematica?

Yes, you can add a legend to your ListPlot in Mathematica by using the PlotLegends option. This allows you to specify the labels for each data series in your plot, as well as customize the appearance of the legend. You can also add a legend to a Manipulate plot by using the PlotLegend option within the Manipulate function.

How do I export my ListPlot in Mathematica as an image or a file?

To export your ListPlot in Mathematica as an image, you can use the Export function. This function takes in the plot object and the desired file format, such as PNG, JPEG, or PDF. You can also specify the file path and name for the exported file. Additionally, you can use the Save As function in the Mathematica interface to export your plot as an image or a file.

Similar threads

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