I am trying to incorporate Interval Sliders in Manipulate to allow the user to select a range to view a given plot. Here is an example that I have constructed for the sake of the question.

opt := {PlotStyle -> Orange, AxesLabel -> {"\[Mu]s", "V"}, 
  ImageSize -> 300}
  Plot[Sin[10/x], {x, 0, 5}, PlotRange -> {{0, 5}, {-1, V}}, 
  Evaluate[opt]], {{V, 0}, -1, 1}, ControlType -> VerticalSlider, 
  ControlPlacement -> Left]

I want to create a vertical Interval Slider to allow the user to control the view of the plot. By having the user choose the appropriate positions of the sliders, the plot should return the Plot with PlotRange -> {{0,5},{Vmin, Vmax}}. Similarly, I also want to create a second horizontal slider in the same panel underneath the displayed plot to mimic the same thing for the x-axis. Does Manipulate support multiple sliders in one function?

Also, very minor follow-up questions: How can I display the values of the Interval Slider and furthermore let the user input some values defining the interval so that the plot displays the range specified by the user?

Thank you so much. I have been fiddling around with ControlType->IntervalSlider but couldn't figure out a way to have Manipulate interpret the parameters that I have set.


This should give you a starting point:

opt = {PlotStyle -> Orange, AxesLabel -> {"\[Mu]s", "V"}, ImageSize -> 300}

 Plot[Sin[10/x], {x, 0, 5}, PlotRange -> {xInt, {vMin, vMax}}, Evaluate[opt]], 
  {{vMax, 0}, -1, 1, VerticalSlider, Appearance -> "Labeled"},
 {{vMin, -1}, -1, 1, VerticalSlider, Appearance -> "Labeled"},
 {{xInt, {0, 5}, Row[{Spacer[40], "x interval"}]}, 0, 5, ControlType -> IntervalSlider, 
  Appearance -> "Labeled", Method -> "Push", MinIntervalSize -> 0.5, ImageSize -> {300, 25}},
 ControlPlacement -> {Left, Right, Bottom}]


  • 1
    $\begingroup$ You can check for example this answer to see how to add interconnected InputFields. $\endgroup$ – Karsten 7. Jul 27 '16 at 0:07
  • 1
    $\begingroup$ Thank you so much. One more followup question. How can you use LocalizeVariables -> False in Manipulate using two interval sliders? $\endgroup$ – Wilson Jul 30 '16 at 19:15
  • 1
    $\begingroup$ @Wilson You mean avoiding the initial red coloring? Use the Initialization option: Initialization :> (vMax = 0; vMin = -1; xInt = {0, 5};) $\endgroup$ – Karsten 7. Jul 30 '16 at 19:57
  • 1
    $\begingroup$ Not exactly, although that would also be nice to add. I am trying to keep the interval sliders at the same values when the user decides to input a new function. For example, if I keep the slider at {1,3} in the x interval slider above and the user decides to plot a new function, Manipulate would change the plot of the graph but keeps the sliders at {1,3}. I think this is done using LocalizeVariables->False but I may be incorrect. Thanks! $\endgroup$ – Wilson Jul 30 '16 at 21:32
  • 1
    $\begingroup$ @Wilson LocalizeVariables->False makes vMax, vMin, and xInt global variables (meaning, e.g., vMax gets defined outside of Manipulate and has the same value as inside Manipulate). Maybe you are looking for SaveDefinitions->True. $\endgroup$ – Karsten 7. Jul 30 '16 at 22:19

Your Answer

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

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