0
$\begingroup$

The Placed function can put a legend on a Plot, but the position will be changed when I change the ImageSize.

Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}, Frame -> True, Axes -> False, 
PlotRangeClipping -> False, PlotLegends -> Placed["Expressions", {0.1, 0.9}], 
ImageSize -> Medium]

Is there a way to fix the legend position by giving coordinates? For example, let the legend left-top corner fix at point (1,1), or let the spacings between the legend and frame be 0.1 image width and 0.1 height.

enter image description here

$\endgroup$
1
  • $\begingroup$ Have you seen Scaled ? $\endgroup$ Nov 1, 2022 at 20:13

1 Answer 1

0
$\begingroup$

I found a way that uses the Scaled function.

Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}, Frame -> True, Axes -> False, 
PlotRangeClipping -> False, PlotLegends -> Placed["Expressions", {Scaled[{0.1, 0.9}], {0, 1}}], AspectRatio -> 1]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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