Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
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
up vote 5 down vote accepted

Perhaps this is the workaround you ask for?

data = RandomReal[{0, 1}, {100, 2}];
nf = Nearest[data];
 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

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}]];
 {pt, Extract[data, pt]},
 {pt, {1, 1}, Dimensions[data], {1, 1}},
 ControlType -> Slider2D


share|improve this answer
Isn't that out of scale if the points aren't equally spaced? – Dr. 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

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.

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

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

enter image description here

share|improve this answer

Your Answer


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.