3
$\begingroup$

Here is a simple Manipulate expression with a threshold.

Manipulate[
  Show[
    Plot[
      Piecewise[{{ξ x^2, x <= 1/(2 ξ - 1)}, {x, x > 1/(2 ξ - 1)}}], {x, 0, 5}], 
    Graphics[Line[{{1/(2 ξ - 1), 0}, {1/(2 ξ - 1), 25}}]]], 
  {ξ, 0, 1, Appearance -> "Labeled"}]

How to label the foot of the threshold line in such a way that it moves with it?

$\endgroup$
3
$\begingroup$

One way is to add a text element in the graphics object:

Manipulate[
 Show[Plot[
   Piecewise[{{ξ x^2, x <= 1/(2 ξ - 1)}, {x, 
      x > 1/(2 ξ - 1)}}], {x, 0, 5}], 
  Graphics[{Line[{{1/(2 ξ - 1), 0}, {1/(2 ξ - 1), 25}}], 
    Text["label", {1/(2 ξ - 1), 0}]}]], {ξ, 0, 1, 
  Appearance -> "Labeled"}]

enter image description here

$\endgroup$
2
$\begingroup$

I differ from xslittlegrass on what you want the label to be. I would modify your code like so:

Manipulate[
  With[{threshold = 1/(2 ξ - 1)},
    Show[
      Plot[
        Piecewise[{{ξ x^2, x <= threshold}, {x, x > threshold}}], {x, 0, 5}],
      Graphics[
        {HalfLine[{threshold, 0}, {0, 1}],
         Text[Round[threshold, .01], {threshold, -2.25}]}],
      PlotRange -> {{0, 5}, {0, 16}},
      PlotRangePadding -> {{Automatic, .1}, {3., Automatic}},
      PlotRangeClipping -> False]],
 {{ξ, .6}, 0.55, 1., Appearance -> "Labeled"}]

demo

This produces a moving label that gives the current value of threshold.

$\endgroup$
2
$\begingroup$
Manipulate[Plot[Piecewise[{{ξ x^2, x <= 1/(2 ξ - 1)}, {x, x > 1/(2 ξ - 1)}}], {x, 0, 5}, 
        GridLines -> {{{1/(2 ξ - 1), Directive[Thick, Red]}}, {}}, 
        Epilog -> Text[Framed[ToString@Round[1/(2 ξ - 1), .1], 
                              Background -> Orange], {1/(2 ξ - 1), -.5}], 
        PlotRangePadding -> .9], 
  {{ξ, .7}, .0, 1, Appearance -> "Labeled"}]

Mathematica graphics

$\endgroup$

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.