Group Abstract Group Abstract

Message Boards Message Boards

1
|
10.6K Views
|
8 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How do I make a frame around a PlotLegend?

Posted 5 years ago
POSTED BY: aryeh Weiss
8 Replies
Posted 5 years ago
POSTED BY: aryeh Weiss
Posted 5 years ago

Got it. The following code works, though I think that there must be an easier way.

PlotLegends -> 
 Placed[LineLegend[{Blue, Green}, {Row[{"Q=", q}], Row[{"Q=", q/a}]}, 
   LegendFunction -> Framed], {0.8, 0.9}],
POSTED BY: aryeh Weiss

Nice to hear that.

Posted 5 years ago

Hi Aryeh,

There is no need to duplicate the colors

PlotLegends -> 
  Placed[LineLegend[{Row[{"Q=", q}], Row[{"Q=", q/a}]}, 
    LegendFunction -> "Frame"], {Right, Top}]]
POSTED BY: Rohit Namjoshi
Posted 5 years ago
POSTED BY: aryeh Weiss

Hi Aryeh, the code looks fine to me. What version of Mathematica are you using? In this situation, by Occam's razor, I will say to you that you need to install the package PlotLegend. if it is installed then try to use the option LegendBorder in PlotLegend instead of Frame. Tell me if this works for you.

Kind regards

Posted 5 years ago

Thank you for your quick response. I added that part of the notebook as a code sample. I think that it will generate the plot in question. When posting a code segment like this, is there a way to run it so that the output is also attached? Best regards --aryeh

`Manipulate[
 pl5 = plotType[{(x ) (1/q)/Sqrt[(1 - (x)^2 )^2 + (x)^2 (1/q)^2   ],
    (x ) (1/q)/Sqrt[(1 - (x)^2 )^2 + (x)^2 (a/q)^2   ]}, {x, 
    lowerLimit, upperLimit}, 
   GridLines -> {{{1, {Thick, Red}}, {1 - 1/(2 q), {Blue, Thick, 
        Dashed}}, {1 + 1/(2 q), {Blue, Thick, Dashed}},
       {1 - a /(2 q), {Green, Thick, Dashed}}, {1 + a/(2 q), {Green, 
        Thick, Dashed}}}, { {1/Sqrt[2], {Thick, Red}}}}, 
   PlotRange -> {{lowerLimit, upperLimit}, {0, 1}},
   LabelStyle -> {FontSize -> 16, FontFamily -> "Times", Black, 
     Bold},
   PlotLegends -> {Placed[{Row[{"Q=", q}], Row[{"Q=", q/a}]}, {0.8, 
       0.9}]},
   PlotStyle -> {Blue, Green}, Frame -> True,  
   FrameLabel -> {None, 
     "\!\(\*SubscriptBox[\(V\), \(R\)]\)/\!\(\*SubscriptBox[\(V\), \
\(IN\)]\)"}];
 pl6 = plotType[{1/Sqrt[(1 - (x)^2 )^2 + (x)^2 (1/q)^2   ],
    1/Sqrt[(1 - (x)^2 )^2 + (x)^2 (a/q)^2   ]}, {x, lowerLimit, 
    upperLimit}, 
   GridLines -> {{{1, {Thick, Red}}, {1 - 1/(2 q), {Blue, Thick, 
        Dashed}}, {1 + 1/(2 q), {Blue, Thick, Dashed}},
       {1 - a /(2 q), {Green, Thick, Dashed}}, {1 + a/(2 q), {Green, 
        Thick, Dashed}}}, { {1/Sqrt[2], {Thick, Red}}}}, 
   PlotRange -> {{lowerLimit, upperLimit}, {0, q}},
   LabelStyle -> {FontSize -> 16, FontFamily -> "Times", Black, 
     Bold},
   PlotLegends -> {Placed[{Row[{"Q=", q}], Row[{"Q=", q/a}]}, {0.8, 
       0.9}]},
   PlotStyle -> {Blue, Green}, Frame -> True,  
   FrameLabel -> {None, 
     "\!\(\*SubscriptBox[\(V\), \(C\)]\)/\!\(\*SubscriptBox[\(V\), \
\(IN\)]\)" }];
 pl7 = plotType[{x^2/Sqrt[(1 - (x)^2 )^2 + (x)^2 (1/q)^2   ],
    x^2/Sqrt[(1 - (x)^2 )^2 + (x)^2 (a/q)^2   ]}, {x, lowerLimit, 
    upperLimit}, 
   GridLines -> {{{1, {Thick, Red}}, {1 - 1/(2 q), {Blue, Thick, 
        Dashed}}, {1 + 1/(2 q), {Blue, Thick, Dashed}},
       {1 - a /(2 q), {Green, Thick, Dashed}}, {1 + a/(2 q), {Green, 
        Thick, Dashed}}}, { {1/Sqrt[2], {Thick, Red}}}}, 
   PlotRange -> {{lowerLimit, upperLimit}, {0, q}},
   LabelStyle -> {FontSize -> 16, FontFamily -> "Times", Black, 
     Bold},
   PlotLegends -> {Placed[{Row[{"Q=", q}], Row[{"Q=", q/a}]}, {0.8, 
       0.9}]},
   PlotStyle -> {Blue, Green}, Frame -> True,  
   FrameLabel -> {"NORMALIZED FREQUENCY", 
     "\!\(\*SubscriptBox[\(V\), \(L\)]\)/\!\(\*SubscriptBox[\(V\), \
\(IN\)]\)" }];
  GraphicsGrid[{{pl5}, {pl6}, {pl7}}, ImageSize -> {750, 1500}],
 {{q, 5}, 0.25, 50}, {{a, 5}, 0.1, 
  50}, {plotType, {LogLinearPlot, Plot}}, {{upperLimit, 100}, {1.2, 
   1.5, 2, 5, 10, 100}}, {{lowerLimit, 0.01}, {0.01, 0.1, 0.5, 0.8}},


 SaveDefinitions -> True]`
POSTED BY: aryeh Weiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard