I am facing a problem in adding a label to a PopupMenu. I have two plots a and b of same size. But when I am adding label to them in PopupMenu, it is changing the size of the plot.

When the Label size is bigger, it compresses the plot so that it adjust to the FieldSize of PopupMenu. But I dont want this.

 a = Manipulate[
       l = DiscretePlot[Cos[a t], {t, 0, 2 Pi, Pi/6}, ExtentSize -> Full, 
       ImageSize -> Scaled[1], AspectRatio -> .25, ImageMargins -> 0, 
       ImagePadding -> 0], 
       Mouseover["vertical", Control[{{a, 1, "a Manipulator"}, 1, 20}]], 
       ControlPlacement -> Bottom];
b = Manipulate[q = Graphics[
     DiscretePlot[Sin[g t], {t, 0, 2 Pi, Pi/6}, ExtentSize -> Full, 
     PlotStyle -> Orange, AspectRatio -> .25, ImageSize -> Scaled[1], 
     ImageMargins -> 0, ImagePadding -> 0]], {g, 1, 10}];

        Dynamic[p], {a ->Labeled[l, (Framed["pop_up_window Plot"]), {Right}, 
                   LabelStyle -> Directive[Bold, FontFamily -> "Helvetica"]], 
                 b -> Labeled[q, (Framed["mouseover Plot"]), {Right}, 
               LabelStyle -> Directive[Bold, FontFamily -> "Helvetica"]]}, 
       FieldSize -> {24, 8}, ImageMargins -> 0, 
       FrameMargins -> 0, ContentPadding -> False, 
       Alignment -> {Center, Center}]}, {Dynamic[p]}}, Spacings -> 20, 
       Alignment -> {Left, Top}]

enter image description here

When I am adding label, then the first plot becomes smaller than the second. I want that Label size should not affect the Plotsize.

  • 1
    $\begingroup$ Could you add an image of what you're seeing, and what you want to see? $\endgroup$ – Mr.Wizard Jul 18 '12 at 8:05
  • $\begingroup$ I am unable to reproduce the behaviour you describe. The plots always have the same size here. Can you avoid using Scaled units in FieldSize? I'm not sure if you're aware that Scaled is relative to the notebook width in this case. Probably this is why I can't reproduce it on a different system. $\endgroup$ – Szabolcs Jul 18 '12 at 8:19
  • $\begingroup$ @Szabolcs: I have edited FieldSize in code. I was not knowing by Scaled, it will not work on different systems $\endgroup$ – Jennifer Jul 18 '12 at 8:29
  • $\begingroup$ I still can't reproduce it on my system, Jennifer. This is what I get using your code: i.stack.imgur.com/t7kqp.png The plots are the same size. The labels do get compressed. $\endgroup$ – Szabolcs Jul 18 '12 at 8:29
  • $\begingroup$ @Ajasja: Yes, so how can I rectify this? $\endgroup$ – Jennifer Jul 18 '12 at 9:13

I am unable to reproduce this behaviour on my system. The plots always have exactly the same size. This is what your code produces here:

But on your system you could try setting the image size explicitly to force a fixed size. Inside Labeled, try replacing q by Show[q, ImageSize -> 100]. Do the same for l. Does this fix the problem?

  • $\begingroup$ One more thing how can I set first plot as default? $\endgroup$ – Jennifer Jul 18 '12 at 12:05
  • $\begingroup$ @Jennifer To have a default value, you can set a value to p before evaluating the PopupMenu. This will be the initial value. It has to match one of the values that the PopupMenu can set to p. $\endgroup$ – Szabolcs Jul 18 '12 at 16:44
  • $\begingroup$ I have tried that too but when I am deploying it in CDF, it is showing p as the output. I want that when I dont select any plot on the popupmenu, then too it should select some plot. $\endgroup$ – Jennifer Jul 18 '12 at 18:55

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.