# How can I mark a point on a slider control?

I have a Slider control inside a Manipulate which spans some range of values, say from 0 to 10, like in:

 Manipulate[
Sin@x,
{x, -2 Pi, 2 Pi}
]


I would like to visually mark some specific value in that range, say x=Pi, for example by placing a coloured circle on the slider corresponding to that value or something similar.

How can I realize something like this?

• I think it will be more handy to use Gauges for this.
– Kuba
May 17, 2015 at 19:40
• @Kuba that could be an acceptable solution. But how can I make only one of the markers on an HorizontalGauge dynamic?
– glS
May 17, 2015 at 21:12

I do this all the time, but use small buttons next to the slider. This is handy when one wants to jump to specific value, and sometimes it is hard to get the slider to go there exactly without few hits and misses and one ends up opening the slider using "+" and typing in the value in the small window which is not very efficient sometimes.

Here is an example

Manipulate[
AccountingForm[v, f, NumberSigns -> {"-", "+"},
tick;
Sin[x],
Grid[{
{Manipulator[
Dynamic[x, {x = #; tick = Not[tick]} &], {-2 Pi, 2 Pi}],
{Row[{Button[Style[-2 Pi, Small], x = -2.0 Pi; tick = Not[tick],
ImageSize -> {40, 20}],Spacer[5],

Button[Style[-Pi, Small], x = -N@Pi; tick = Not[tick],
ImageSize -> {40, 20}], Spacer[5],

Button[Style[0, Small], x = 0.; tick = Not[tick],
ImageSize -> {40, 20}], Spacer[5],

Button[Style[Pi, Small], x = N@Pi; tick = Not[tick],
ImageSize -> {40, 20}], Spacer[5],

Button[Style[2 Pi, Small], x = 2.0 Pi; tick = Not[tick],
ImageSize -> {40, 20}], Spacer[5]}
]}
}],
{{tick, False}, None},
{{x, N@Pi}, None},
TrackedSymbols :> {tick}
]


I kept the values numerical to remove any shifting in display as the slider moves.

• Thanks for the solution and the very useful code. I don't accept this answer only because I'm also curious to know how can the slider be tweaked to actually add a marker of some sort on it
– glS
May 18, 2015 at 20:21
• Just one thing: what is the purpuse of the tick variable you added?
– glS
May 18, 2015 at 20:29
• @glance the tick is the control variable used to control everything. a control variable has to appear in the Manipulate expression somewhere to be tracked. May 20, 2015 at 8:45