I find myself extremely confused about how Placed
works with plot legends. I want my legend to partially hang over one edge of the plot. But
Plot[Sin[x], {x, -1, 1}, PlotLegends -> Placed[{"Sine"}, {.975, .75}]]
produces
which is no good because the label gets cut off. As soon as I increase the first coordinate up to 1, it works okay, but space is really tight in my desired application and I can't afford to waste all that white space under the curve.
I've tried using the optional second pair of coordinates in Placed
, but I can't figure out how they work - When I hold the first pair fixed and change the values of the second pair, they seem to be moving my legend in the opposite direction as I would expect (e.g. changing the coordinates to {{1, .75}, {2, 0}}
moves the legend to the left), and I also have no idea what's setting the scaling of the second pair of coordinates.
I found the question Legend placement explanation, but I can't follow the example because it has so much extraneous crap in it and the answers don't go into enough detail. Not much detail in the documentation for Placed
either.
Would this maybe be a job for Show
, Inset
, or Overlay
? I'm not really sure about their relative advantages.
Finally, I noticed that using Placed
changes the legend's text from left-aligned to centered. How do I change it back?
Edit: Regarding my last question, the easiest way to change the text alignment of the legend is to change {"Sine"}
to LineLegend[{"Sine"}, LabelStyle -> {TextAlignment -> Left}]
.
PlotRangeClipping -> False, ImagePadding -> {{Automatic, 20}, {Automatic, Automatic}}
you can prevent clipping and extend the 'plot' region to encompass the whole label. $\endgroup$