Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have the following MWE

Show[
 Plot[x, {x, 0, 2}, Frame -> True, 
  FrameLabel -> {Style["frequency", Medium], 
    Style["\!\(\*SubscriptBox[\(v\), \(mean\)]\)", Medium]}, 
  PlotLegends -> {"asd"}],
 ListPlot[{{0.5, 0.25}, {1, 0.5}}, PlotStyle -> Red, 
  PlotLegends -> {"asd"}]]

There are several things I am trying to do, which I can't get to work. I will list them here

  1. How can I make the two legends be inside the graph, not outside?
  2. How can I make the legends be aligned over/under eachother, exactly? Now the are aligned to the left.
  3. I am really interested in finding a way to alter the size of the FrameLabel, ticks and legends in a easy way. So far I have only been able to do it by using Small, Medium and Large, but that is not very dynamic.
share|improve this question

2 Answers 2

up vote 4 down vote accepted

I find it easier to put this type of legend together by hand, as follows:

Legended[
  Show[ (* fill in with plots without PlotLegends option *) ],
  LineLegend[{ColorData[1][1], Red}, {"asd", "asd"}, Joined -> {True, False}]
]

enter image description here

The disadvantage is you lose the automatic color generation, but you gain control and it is automatically formatted as you would like. The next step is to place it where you want it, and you do that using Placed. For this, I would use either

Placed[legend, {Right, Center}] (* or, Top, Bottom, or Left with Center *)

or

Placed[legend, Scaled[{0.5, 0.9}]

which gives

enter image description here

share|improve this answer

Lets start with assumption that We do not want to create legend from the beginning. You can put PlotLabel inside using Placed and allign content with 3rd argument of Placed.

Show[{
  Plot[x, {x, 0, 2}, Frame -> True, 
   FrameLabel -> {Style["frequency", Medium], 
     Style["v", Medium]}, 
   PlotLegends -> 
    Placed[{"asd"}, {Right, Center}, 
     Pane[#, 60, Alignment -> Center] &]]
  ,
  ListPlot[{{0.5, 0.25}, {1, 0.5}}, PlotStyle -> Red,
   PlotLegends -> 
      Placed[{"asd"}, {Right, Center}, 
       Pane[#, 60, Alignment -> Center] &] ]
  }
 ]

enter image description here

I'm not going to describe creating new legend because of rcollyer answer :) And as He has said, each method has adventages and disadventages. Honestly, his is more convenient for me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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