Message Boards Message Boards

0
|
2619 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to align a text inside a plot?

Posted 3 years ago

Hi, I have a text to be aligned inside a plot at a desired location (top right). I used the Show command followed by Graphics and Text. But I'm unable to take my text to the location.

in my code the text is "(b)" which is to be brought to the top right location.

My code:

y = Range[1, 10];
x = Range[1, 10];
visco = 12*10^-6;
x = -p22*(1/xi - I k);
y = (-q11*(1/xi - I k) - 
     x*(q22*(1/xi + I k) - q33*(1/xi + I k)*(I k - 1/xi) - 
        q44*(1/xi^2 + k^2) - q55*(1/xi - I k)))/(p22 + 
     p33*(I k - 1/xi) - p55*(1/xi^2 + k^2));
y = y*10^-21;
Show[Plot[{Im[y] /. {xi -> 100}, Re[x] /. xi -> 50, 
   Re[x] /. xi -> 10}, {k, 0, 100}, PlotRange -> All, 
  PlotStyle -> {Directive[Red, Thick], Directive[Blue, Dashed, Thick],
     Directive[Black, Thick, Dashed]}, Frame -> True, 
  FrameStyle -> Directive[Black, Thickness@0.0125], 
  PlotLegends -> 
   Placed[LineLegend[{Style["\[Xi] = 100", Bold, 14], 
      Style["\[Xi] = 50", Bold, 14], Style["\[Xi] = 10", Bold, 14]}, 
     LegendFunction -> None, LegendLayout -> "Column"], {Left, Top}], 
  FrameLabel -> {"K", 
    "\!\(\*SubscriptBox[\(\[CapitalOmega]\), \(i\)]\)"}, 
  LabelStyle -> Directive[Black, Bold, 14], RotateLabel -> True, 
  AspectRatio -> 0.5, 
  FrameTicks -> {{Charting`ScaledTicks[{10^9 # &, #/10^9 &}], 
     None}, {Automatic, None}}], 
 Graphics[Text[Style["(b)", FontSize -> 14, Black], {97, 97}]]]

Kindly advice.

Rgds.

POSTED BY: Rahul Chakrabory
3 Replies

The scaled coordinates range from 0 to 1. Left top is {0,1}, center top is {.5,1}. Then you may have to adjust the offset:

Text[Style["(b)", FontSize -> 14, Black], Scaled[{0, 1}], {-1, 1}]
Text[Style["(b)", FontSize -> 14, Black], Scaled[{.5, 1}], {0, 1}]

Confusingly enough, the offset range is from -1 to 1.

POSTED BY: Gianluca Gorni

This is a way:

Text[Style["(b)", FontSize -> 14, Black], Scaled[{1, 1}], {1, 1}]
POSTED BY: Gianluca Gorni

Thanks, the text is getting to the desired location i.e. to the right top corner of the plot. Now, I tried to scale the coordinates so as to get the text to left top, or to the centre top. I changed the coordinates to (-1,-1) or (0,1) etc. But its not going there.

POSTED BY: Rahul Chakrabory
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