Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
data = Sort[RandomReal[{0, 1}, {100, 2}]];
Manipulate[pt, {pt, data}, ControlType -> Slider2D]

I get a error message:

Manipulate::vstype: ControlType -> Slider2D is not supported for the variable specification

Is there a workaround?

What I'm trying to achieve is something like this

{Slider2D[Dynamic[pt1], {{0, 0}, {1, 1}, {0.5, 0.5}}], Dynamic[pt1]}

here pt1 can take from

{{0, 0}, {0, 0.5}, {0, 1}, {0.5, 0}, {0.5, 0.5}, {0.5, 1}, {1, 0}, {1,0.5}, {1, 1}}

. Now I want to use my own data, which may contain points that are not equally space.

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

Perhaps this is the workaround you ask for?

SeedRandom[1];
data = RandomReal[{0, 1}, {100, 2}];
nf = Nearest[data];
Manipulate[
 Graphics[{Point[data], Red, PointSize[Large], Dynamic@Point[pt]}],
 {{pt, First@data}, Slider2D[Dynamic[pt, (pt = First@nf[#]) &]] &}]

Mathematica graphics

share|improve this answer
    
Yes that's exactly what I'm looking for. Thanks a lot. –  xslittlegrass Sep 21 '13 at 17:14
add comment

You can let pt take on values corresponding to a position in data and Extract the value there:

data = Sort[RandomReal[{0, 1}, {100, 2}]];
Manipulate[
 {pt, Extract[data, pt]},
 {pt, {1, 1}, Dimensions[data], {1, 1}},
 ControlType -> Slider2D
 ]

manipulate

share|improve this answer
1  
Isn't that out of scale if the points aren't equally spaced? –  belisarius Sep 21 '13 at 0:51
    
@ssch In your example the y of the 2d slider seems only have two value, but what I'm aiming for is allowing the 2d slider to represent the position of the point, whereas your 2d slider seems to represent the point index. –  xslittlegrass Sep 21 '13 at 1:32
add comment

I'm not sure what you are really asking because the question does not seem internally self-consistent, but perhaps this is what you are looking for.

SeedRandom[42];
data = Sort[RandomReal[{0, 1}, {100, 2}]];
data = Partition[data, 10];
data = SortBy[#, Last] & /@ data;

Manipulate[
 {pt, Extract[data, pt]}, 
 {pt, {1, 1}, {10, 10}, {1, 1}}]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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