# Slider with ticks

Mathematica Asked by Artem on October 19, 2020

I am not happy with the "Labeled" appearance of the slider in Animate or Manipulate. Instead, I wish ticks with multiple of pi under the slider.

Animate[Plot[Sin[x + phi], {x, 0, 2 Pi}], {phi, 0, 2 Pi,
Appearance -> "Labeled"}]


What would be the best way to do it?
Ideally it should look like this: I do not think the solution given in
https://mathematica.stackexchange.com/a/8264
is practical or even elegant. Following this logic of adding an additional axis I cannot make it look the way I want and, in general, it seems highly "artificial".

1. You can use HorizontalGauge as a control in Manipulate:

Manipulate[Plot[Sin[x + phi], {x, 0, 2 Pi}],
{phi, 0, 2 Pi, Panel[HorizontalGauge[##, ScaleDivisions -> None,
Axes -> {True, False}, ImageSize -> 250,
Ticks -> {Transpose[{Subdivide, Subdivide[0, 2 Pi, 8]}], None}], #, Right] &}] To allow only discrete values, say multiples of Pi/4, for the control variable phi:

Manipulate[Plot[Sin[x + phi], {x, 0, 2 Pi}],
{phi, 0, 2 Pi, Panel[HorizontalGauge[Dynamic[phi, (phi = Round[#, Pi/4]) &], ##2,
ScaleDivisions -> None, ImagePadding -> 15,
PlotRange -> {{0, 1}, Automatic},
Axes -> {True, False}, ImageSize -> 250,
Ticks -> {Thread[{Subdivide, Subdivide[## & @@ #2, 8], {0, .05}},
List, 2], None}], #, Right] &}] 2. Alternatively, you can use a poor-man's custom control that combines a slider and an empty graphics with horizontal axis:

Manipulate[Plot[Sin[x + phi], {x, 0, 2 Pi}],
{phi, 0, 2 Pi, Labeled[Panel @ Column[{Slider[##, ImageSize -> 250],
Graphics[{}, Axes -> {True, False},
Ticks -> {Subdivide[## & @@ #2, 8], None}, ImageSize -> 250,
PlotRange -> {#2, {0, .05}}]}, Alignment -> Center,
Spacings -> 0], #, Right] &}] 3. We can also modify the function ValueThumbSlider from tutorial/AdvancedManipulateFunctionality >> CustomControl Appearances to get a custom slider with axis:

ClearAll[sliderWithAxis]
sliderWithAxis[Dynamic[var_], {min_, max_, d_}, o : OptionsPattern[]] :=
LocatorPane[Dynamic[If[! NumberQ[var], var = min];
{var, 0}, (var = First[#]) &],
Panel[Graphics[{Dynamic[
Polygon[Offset[#, {var, 0}] & /@ {{0, 5}, {-5, 15}, {5, 15}}]]},
o, ImageSize -> 300, ImagePadding -> {{15, 15}, {30, 5}},
Axes -> {True, False},
Ticks -> {{#, #, {0, .025}} & /@ Range[min, max, d], None},
PlotRange -> {{min, max}, {-1, 1}}, AspectRatio -> 1/10],
Dynamic[Style[Round[var, d], 16]], Right, Background -> LightBlue,
Alignment -> Center],
{{min, 0}, {max, 0}, {d, 0}}, Appearance -> None]

Manipulate[ Plot[{Sin[x + phi], Cos[x + psi]}, {x, 0, 2 Pi}],
{phi, 0, 2 Pi, Pi/4, sliderWithAxis[##] &},
{psi, 0, 2 Pi, Pi/2, sliderWithAxis[##] &}] Correct answer by kglr on October 19, 2020

## Related Questions

### Fix two data lists intertwined

2  Asked on August 22, 2021

### Help to create a 2D mesh generator (FEM)

1  Asked on August 22, 2021

### Two-dimensional Laplacian coupled with another equation leading to a BVP with integral bc(s)

2  Asked on August 22, 2021

### Enter without execute

2  Asked on August 22, 2021

### Plotting two functions into one plot with two y-axes. Is there a built option for this in newer versions of Mathematica?

1  Asked on August 22, 2021

### How do I replace specific sequences of a sublist without changing the level of the list?

2  Asked on August 22, 2021 by kycygni

### How to use MMA to simulate the German tank problem

2  Asked on August 22, 2021

### Giving a range to Plot to plot multiple lines at the same time

3  Asked on August 22, 2021

### How to decompose a list of n-tuples into a union of Cartesian products

2  Asked on August 22, 2021 by martin-leung

### Possible error with Series expansion

2  Asked on August 22, 2021 by miguel-oliveira

### Mathematica emits a beep after any evaluation – how to remove it?

2  Asked on August 22, 2021

### Export NetCDF Dimension Name

1  Asked on August 22, 2021 by user1139069

### Convert huge (10-100MB of plain text) Mathematica function for external use

0  Asked on August 22, 2021 by phys

### Why Mathematica doesn’t give output for Integration of Special Function

0  Asked on August 22, 2021 by nilabh

### Prony series with a large number of terms

2  Asked on August 22, 2021

### Breaking “Functional Loops” and Doing Lazy Evaluation In Mathematica

2  Asked on August 22, 2021 by dskeletov

### How to calculate the total area of $frac{cos (2 y) cos (2 x-y)+cos (3 y)}{cos (2 x-y)+cos (y)}$ enclosed in the range $[0,1]$?

5  Asked on August 19, 2021

### interact with web pages with many hyperlinks and search for a specific name or phrase How?

1  Asked on August 19, 2021

### NestList in 12.1/12.2 is 10x slower than 11.3/12.0

0  Asked on August 18, 2021