2
$\begingroup$

For example, I have the bellow code:

Manipulate[
  Plot[invert*Sin[x], {x, -Pi, Pi}],
  {{invert, 1}, {1 -> "reset", -1 -> "invert"}}
]

Even though I set the label of SetterBar as Null, (refering the bellow codes), there is still a small blank.

Manipulate[
  Plot[invert*Sin[x], {x, -Pi, Pi}],
  {{invert, 1, Null}, {1 -> "reset", -1 -> "invert"}}
]

How can I remove the label within red circle, no blank left, i.e. "reset" laid left most.

enter image description here

$\endgroup$
4
  • 1
    $\begingroup$ That's weird, I'm not seeing a label on Mathematica 11.2. What version are you using? $\endgroup$ Oct 18, 2017 at 11:13
  • $\begingroup$ notice there is a margin for a label too, if you want precise control, use DynamicModule+ Column etc. $\endgroup$
    – Kuba
    Oct 18, 2017 at 11:15
  • $\begingroup$ @numbermaniac My platform is also Mathematica 11.2 on Windows 10. There do be some margin (please refer to my post bellow). $\endgroup$
    – PureLine
    Oct 18, 2017 at 15:22
  • $\begingroup$ @Kuba Thanks, I have worked out a solution following your advice. $\endgroup$
    – PureLine
    Oct 18, 2017 at 15:23

2 Answers 2

3
$\begingroup$

I don't know how to do it using Manipulate's shortcut control specification, but I can show you how to do it by specifying the setter bar in full control form.

Manipulate[
  Plot[invert*Sin[x], {x, -Pi, Pi}],
  Framed[
    Control[{{invert, 1, ""}, {1 -> "reset", -1 -> "invert"}}],
    FrameMargins -> {{-12, 0}, {0, 0}},
    FrameStyle -> Transparent]]

plot

$\endgroup$
3
  • $\begingroup$ I worked out a solution following advice from @Kuba . But your new answer is still better than mine. ^_^ '''' It's more precise. $\endgroup$
    – PureLine
    Oct 18, 2017 at 15:20
  • $\begingroup$ @PureLine. I didn't give you any advice. It was Kuba who gave advice. $\endgroup$
    – m_goldberg
    Oct 18, 2017 at 15:23
  • $\begingroup$ I've corrected it. 囧rz.... @m_goldberg $\endgroup$
    – PureLine
    Oct 18, 2017 at 15:28
1
$\begingroup$

Thanks for @Kuba. I think I have made it.

Firstly, I will show my previous solution with Manipulate:

Manipulate[ (* Note: I use Null to delete the label *)
  Plot[invert*Sin[x], {x, -Pi, Pi}], {{invert, 1, Null}, {1 -> "reset", -1 -> "invert"}, 
  Appearance -> "Vertical"}, ContentSize -> {360, 240}]

Above codes output:

enter image description here

Following @Kuba 's suggestion, I crafted my codes as following:

DynamicModule[{invert = 1}, 
  Framed@Column[{Dynamic[invert], {1 -> "Reset", -1 -> "Invert"}, Appearance -> "Vertical"], 
     Framed[Dynamic[Plot[invert*Sin[x], {x, -Pi, Pi}, ImageSize -> {360, 240}]], 
       FrameStyle -> Gray]}]]

Which produced:

enter image description here

Apparently, the first one generated by Manipulate has some blank space before reset button. And DynamicModule can eliminate the margin.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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