진드기가있는 슬라이더

Aug 21 2020

Animate 또는 Manipulate에서 슬라이더의 "레이블이있는"모양이 마음에 들지 않습니다. 대신 슬라이더 아래에 여러 파이가있는 틱을 원합니다.

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

이를 수행하는 가장 좋은 방법은 무엇입니까? 이상적으로는 다음과 같아야합니다.

나는 주어진 해결책을 생각하지 않는다 https://mathematica.stackexchange.com/a/8264실용적이거나 우아합니다. 축을 추가하는이 논리를 따르면 원하는대로 만들 수 없으며 일반적으로 매우 "인공적인"것처럼 보입니다.

답변

12 kglr Aug 21 2020 at 11:38

1. 다음HorizontalGauge 에서 컨트롤로 사용할 수 있습니다 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[8], Subdivide[0, 2 Pi, 8]}], None}], #, Right] &}]

Pi/4제어 변수에 대해 불연속 값 (예 :의 배수) 만 허용하려면 다음 을 수행하십시오 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[8], Subdivide[## & @@ #2, 8], {0, .05}}, 
          List, 2], None}], #, Right] &}]

2. 또는 슬라이더와 빈 그래픽을 수평 축과 결합하는 가난한 사람의 사용자 지정 컨트롤을 사용할 수 있습니다.

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. 또한 tutorial / AdvancedManipulateFunctionality >> CustomControl AppearancesValueThumbSlider 에서 함수 를 수정하여 축이있는 사용자 지정 슬라이더를 얻을 수 있습니다.

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[##] &}]