# Manipulating Frame labels when legends are also there

I am plotting a few curves inside a frame with labels on three of its sides; left, right and bottom. I want legends to be places at the top. The problem which I am facing is that the top label occupies white space and I want it not to do so. In the code it is labeled as "I want this removed". Please guide me how can I remove the top label completely leaving no gap between frame and legends.

Plot[{Sin[h],Cos[h],Tan[h]},{h,5,10},
PlotStyle->{{GrayLevel[0],Dashing[None],Thickness[0.005]},
{GrayLevel[0],Dashing[Tiny],Thickness[0.005]},
{GrayLevel[0],Dashing[Small],Thickness[0.005]},
{GrayLevel[0], Dashing[Medium],Thickness[0.005]}},
Axes -> False,
Frame -> True,
FrameLabel->{{"Left", Rotate["Right",180 Degree]},{"Bottom","I want this removed"}},
PlotLegends -> Placed[LineLegend[Automatic, {"sin", "cos", "tan"},
LegendMarkerSize->{{45, 15}}],Top]]

-

One way is to put None instead of "Top" as follows:

Plot[{Sin[h], Cos[h], Tan[h]}, {h, 5, 10},
PlotStyle -> {{GrayLevel[0], Dashing[None],
Thickness[0.005]}, {GrayLevel[0], Dashing[Tiny],
Thickness[0.005]}, {GrayLevel[0], Dashing[Small],
Thickness[0.005]}, {GrayLevel[0], Dashing[Medium],
Thickness[0.005]}}, Axes -> False, Frame -> True,
FrameLabel -> {{"Left", Rotate["Right", 180 Degree]}, {"Bottom",
None}},

PlotLegends ->
Placed[LineLegend[Automatic, {"sin", "cos", "tan"},
LegendLayout -> "Row", LegendMarkerSize -> {{45, 15}}], {0.5,
1.002}]]


Then you get this:

If you need to have an additional label on top above the legends, use Column to combine them as here:

  Column[{
Style["top", 10, "Times New Roman"],
Plot[{Sin[h], Cos[h], Tan[h]}, {h, 5, 10},
PlotStyle -> {{GrayLevel[0], Dashing[None],
Thickness[0.005]}, {GrayLevel[0], Dashing[Tiny],
Thickness[0.005]}, {GrayLevel[0], Dashing[Small],
Thickness[0.005]}, {GrayLevel[0], Dashing[Medium],
Thickness[0.005]}}, Axes -> False, Frame -> True,
FrameLabel -> {{"Left", Rotate["Right", 180 Degree]}, {"Bottom",
None}},

PlotLegends ->
Placed[LineLegend[Automatic, {"sin", "cos", "tan"},
LegendLayout -> "Row", LegendMarkerSize -> {{45, 15}}], {0.5,
1.001}], ImageSize -> 300
]
}, Alignment -> Center]


which gives the following picture:

However, what I usually do is the following:

 Plot[{Sin[h], Cos[h], Tan[h]}, {h, 5, 10}, PlotRange -> {-3.5, 4.5},
PlotStyle -> {{GrayLevel[0], Dashing[None],
Thickness[0.005]}, {GrayLevel[0], Dashing[Tiny],
Thickness[0.005]}, {GrayLevel[0], Dashing[Small],
Thickness[0.005]}, {GrayLevel[0], Dashing[Medium],
Thickness[0.005]}}, Axes -> False, Frame -> True,
FrameLabel -> {{"Left", Rotate["Right", 180 Degree]}, {"Bottom",
"Top"}},

PlotLegends ->
Placed[LineLegend[Automatic, {"sin", "cos", "tan"},
LegendLayout -> "Column", LegendFunction -> "Frame",
LegendMarkerSize -> {{45, 15}}], {0.85, 0.77}]]


yielding this:

-
This provides more flexibility and I think its a better way. Legends also look more beautiful this way. gratitude! –  naveed Aug 14 '13 at 16:22

You mean Like this? You can adjust ImagePadding on all 4 edges. It has the same layout for all other Frame related options

Plot[{Sin[h], Cos[h], Tan[h]}, {h, 5, 10},
PlotStyle -> {{GrayLevel[0], Dashing[None], Thickness[0.005]},
{GrayLevel[0], Dashing[Tiny], Thickness[0.005]}, {GrayLevel[0],
Dashing[Small], Thickness[0.005]}, {GrayLevel[0], Dashing[Medium],
Thickness[0.005]}},
Axes -> False, Frame -> True,
FrameLabel -> {{"Left", Rotate["Right", 180 Degree]}, {"Bottom",
"I want this removed"}},
PlotLegends -> Placed[LineLegend[Automatic, {"sin", "cos", "tan"},
LegendMarkerSize -> {{45, 15}}], Top],
ImagePadding -> {{30, 30}, {30, 2}}
]


before

-
Not quite I am afraid. The picture you Posted can be achieved by just removing the labels. As I mentioned in question three of them are required. Just top label is the problem. I know I can remove it by removing text from "" marks but it will then leave white space and legends will be at some distance. I want that distance to be removed keeping other three labels at their places. –  naveed Aug 14 '13 at 3:16
Ok this makes sens now. Let me check what have you done. –  naveed Aug 14 '13 at 3:17
yes you did the right thing. Webpage was not refreshed properly so I could not see other labels. I thought you removed all of them. This is what i wanted. Now i will learn more about ImagePadding. Rest is up to me thanks for your kind help. –  naveed Aug 14 '13 at 3:21