When you use a slider control for any kind of list plots slider should only take integer values and I can specify that with start point and end with step size. However, you can expand the slider and enter a value there such as 4.1. This will cause a failure because the list index can only be integer (shown in the figure). I have a solution (tricky one) but I was wondering if there is a way to avoid expending the slider controls.

enter image description here

My solution

    h[x_, y_] := Sin[2 x + y] Cos[2 y x] ;
    xabs = {0, 10., 0.5};
    yabs = {0, 10., 0.5};
    data = Table[
    Evaluate@N[h[x, y]], {x, xabs[[1]], xabs[[2]], xabs[[3]]}, {y, 
    yabs[[1]], yabs[[2]], yabs[[3]]}];
    Manipulate[ListLinePlot[data[[All, Round[i]]]], 
    Control[{{i, 1, 
    Row[{Style["y position: ", Blue, 12, Bold], 
    Style[(Round[i]*yabs[[3]]) - yabs[[3]], Red, 12]}], 
    ImageSize -> {110, 45}]}, 1, 10, 1}]]

My solution is to use Round[] both data and also in the Panel. Is there a way, not to allow to expand the slider control? This way the user can't use any other value than allowed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.