Message Boards Message Boards

0
|
8215 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to hide a line in a plot legend?

Posted 10 years ago

Hello. I have the following code:

FQ = Plot[{QBER}, {x, 0, NN}, PlotStyle -> {Thin, Black}, 
   PlotLegends -> Placed[{"Expected QBER"}, {Right, Right}]];

Figt = ListPlot[{BLt, CUt}, PlotRange -> {-0.01, 0.2}, Joined -> True,
    PlotStyle -> {Directive[Cyan, Thick], Directive[Magenta, Thick]}, 
   PlotMarkers -> {{"\[FilledCircle]", 4}, {"\[FilledCircle]", 4}}, 
   PlotLegends -> 
    Placed[{"Expected \!\(\*SubscriptBox[\(QBER\), \(LB\)]\), Eq. \
(7)", "Expected \!\(\*SubscriptBox[\(QBER\), \(UB\)]\), Eq. (8)"}, \
{Right, Right}]];

FLB = ListPlot[{Transpose[{x[NN], AQ}], Transpose[{x[NN], BL}]}, 
   Filling -> {1 -> {2}}, 
   PlotMarkers -> {{"\[FilledCircle]", 4}, {"-", 12}}, 
   PlotStyle -> {{Blue}, {Red}}, PlotRange -> {-0.01, 0.2}, 
   PlotLegends -> 
    Placed[{"\!\(\*OverscriptBox[\(QBER\), \(^\)]\)", 
      "\!\(\*SubscriptBox[\(QBER\), \(LB\)]\), Eq. (7)"}, {Right, 
      Right}]];

FUB = ListPlot[{Transpose[{x[NN], AQ}], Transpose[{x[NN], CU}]}, 
   Filling -> {2 -> {1}}, 
   PlotMarkers -> {{"\[FilledCircle]", 4}, {"-", 12}}, 
   PlotRange -> {-0.01, 0.2}, PlotStyle -> {{Blue}, {Green}}, 
   PlotLegends -> 
    Placed[{"\!\(\*OverscriptBox[\(QBER\), \(^\)]\)", 
      "\!\(\*SubscriptBox[\(QBER\), \(UB\)]\), Eq. (8)"}, {Right, 
      Right}]];

gg = Plot[{Eq9[QBER, i], Eq10[QBER, i]}, {i, 0, NN}, 
   PlotRange -> {-0.01, 0.2}, PlotStyle -> {Red, Green}, 
   PlotLegends -> 
    Placed[{"\!\(\*SubscriptBox[\(QBER\), \(LB\)]\), Eq. (9)", 
      "\!\(\*SubscriptBox[\(QBER\), \(UB\)]\), Eq. (10)"}, {Right, 
      Right}]];

Show[Figt, FUB, FLB, FQ, gg, 
 AxesLabel -> {"\!\(\*SubscriptBox[\(N\), \(w\)]\)", 
   "\!\(\*OverscriptBox[\(QBER\), \(^\)]\)"}]

which gives me a nice plot with legend. However, as you can see, the "\!(*OverscriptBox[(QBER), (^)])" appears twice, in FLB and FUB. If I put 'None' instead of the second "\!(*OverscriptBox[(QBER), (^)])" for example, the legend will desappear, but the plot mark for "\!(*SubscriptBox[(QBER), (UB)]), Eq. (8)" will appear as dot instead of a dash. Anyone knows how to delete the duplicated legend and keep the next ones okey?

Thank you.

POSTED BY: Alvaro Almeida
4 Replies
Posted 10 years ago

Hello. Thank you so much. I only needed to do a few changes and it worked. In order to help others that might have the same problem, what I have done was the following:

FUB = ListPlot[{Transpose[{x[NN], CU}], Transpose[{x[NN], AQ}]}, Filling -> {2 -> {1}}, PlotMarkers -> {{"-", 12}, {" ", 12}}]];

Basically I have changed the order of x and y.

POSTED BY: Alvaro Almeida

Hi Alvaro,

Try to change FUB to

FUB = ListPlot[{Transpose[{x[NN], AQ}], Transpose[{x[NN], CU}]}, Filling -> {2 -> {1}}, PlotMarkers -> {{"\[FilledCircle]", 4}, {"-", 12}}, PlotStyle -> {Blue, Green}, PlotLegends -> LineLegend[{None, "\!\(\*SubscriptBox[\(QBER\), \(UB\)]\), Eq. (8)"}, Joined -> True]];
POSTED BY: MinHsuan Peng
Posted 10 years ago

Hello. Thank you for your time helping me.

Unfortunately it is not working yet. Right now I cannot share the full code, since it is part of a working paper. However I'll try to share the maximum information that I can in order for you to be able to help me.

So, the code for the plot is this one:

FQ = Plot[{QBER}, {x, 0, NN}, PlotStyle -> {Thin, Black}, PlotLegends -> Placed[{"Expected QBER"}, {Right, Right}]];
Figt = ListPlot[{BLt, CUt}, Joined -> True, PlotStyle -> {Directive[Cyan, Thick], Directive[Magenta, Thick]}, PlotMarkers -> {{"\[FilledCircle]", 4}, {"\[FilledCircle]", 4}}, PlotLegends -> Placed[{"Expected \!\(\*SubscriptBox[\(QBER\), \(LB\)]\), Eq. \(7)", "Expected \!\(\*SubscriptBox[\(QBER\), \(UB\)]\), Eq. (8)"}, \{Right, Right}]];
FLB = ListPlot[{Transpose[{x[NN], AQ}], Transpose[{x[NN], BL}]}, Filling -> {1 -> {2}}, PlotMarkers -> {{"\[FilledCircle]", 4}, {"-", 12}}, PlotStyle -> {Blue, Red}, PlotLegends -> Placed[{"\!\(\*OverscriptBox[\(QBER\), \(^\)]\)", "\!\(\*SubscriptBox[\(QBER\), \(LB\)]\), Eq. (7)"}, {Right, Right}]];
FUB = ListPlot[{Transpose[{x[NN], AQ}], Transpose[{x[NN], CU}]}, Filling -> {2 -> {1}}, PlotMarkers -> {{"\[FilledCircle]", 4}, {"-", 12}}, PlotStyle -> {Blue, Green}, PlotLegends -> Placed[{"\!\(\*OverscriptBox[\(QBER\), \(^\)]\)", "\!\(\*SubscriptBox[\(QBER\), \(UB\)]\), Eq. (8)"}, {Right, Right}]];
gg = Plot[{Eq9[QBER, i], Eq10[QBER, i]}, {i, 0, NN}, PlotStyle -> {Red, Green}, PlotLegends -> Placed[{"\!\(\*SubscriptBox[\(QBER\), \(LB\)]\), Eq. (9)", "\!\(\*SubscriptBox[\(QBER\), \(UB\)]\), Eq. (10)"}, {Right, Right}]];
Show[Figt, FUB, FLB, FQ, gg, PlotRange -> {-0.01, 0.2}, AxesLabel -> {"\!\(\*SubscriptBox[\(N\), \(w\)]\)", "\!\(\*OverscriptBox[\(QBER\), \(^\)]\)"}];

What I get from this code is the following:

enter image description here

and you can see the fourth line of the legend is equal to the second (inside the red box).

However if I use what you suggest and which I have tryed before I get the following:

enter image description here

As you can see inside the repeated legend is now longer there, however I have another problem, which is: the plot mark is a dot instead of a dash. The only thing that I changed was "\!\(\*OverscriptBox[\(QBER\), \(^\)]\)" to None in FUB. How did he changed the dash to dot? How can I get the dash is it is plotted?

So, this is the main problem that I have here. Based on what I just provided, can you find a solution for it?

POSTED BY: Alvaro Almeida

Hi Alvaro,

If you could put a screenshot of your result or give a working code, it will be clearer to me what you are asking. In the meanwhile, I hope this answer your question.

Plot[{x, x + 1}, {x, 0, 1}, PlotStyle -> {Red, Green}, PlotLegends -> Placed[{None, "b"}, Right]]

showing<em>partlegend

POSTED BY: MinHsuan Peng
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract