1
votes

I want to Plot a function combined with different ListPlots. But i want only one ListPlot at a time displayed. Therefore i want to use Manipulate. My Code looks something like this.

 test1 = Import["/Users/xx/Documents/xxx/test1.csv"];
 test2 = Import["/Users/xx/Documents/xxx/test1.csv"];
 test3 = Import["/Users/xx/Documents/xxx/test1.csv"];

 importList:={test1,test2,test3};
 import:=.;

 Manipulate[
 Show[Plot[MAnt[t], {t, 0, 5}], 
 ListPlot[import]], {import, importList}, LocalizeVariables -> False, TrackedSymbols :>{import}]

I do this a lot with plots of different functions, but i don't get it to work with lists. Any ideas?

Edit1: Well obviously Mathematica joins the three lists together. Can I prevent Mathematica from doing this?

 importList:={"test1","test2","test3"}

Won't work either.

1
after posting my answer, the only thing fundamentally wrong with your code is the import:=.; which is a syntax error and not needed, just get rid of it. (and Clear[import]) However when you make it work the next problem is Manipulate will make huge buttons listing the entirety of the list as the button label. - agentp

1 Answers

0
votes

This simple example might help:

data = {{0, 5, 10, 15} , {1, 4, 9, 16}}
Manipulate[ 
       Show[ 
             Plot[t^2, {t, 0, 4}, PlotStyle -> Red], 
             ListPlot[data[[u]], Joined -> True], 
             PlotRange -> {0, 20}
       ], {u, {1, 2}}
]

To your other question, if you dont wish to join your lists together you could do this:

test[1] = Import..
test[2] = Import ..

Then in Manipulate use test[u] (single brackets)