1
$\begingroup$
dat1krafull = {{1.`, 2.61594`*^-8}, {10.`, 7.10017`*^-9}, {50.`, 

2.1565*^-9}, {75., 1.6567*^-9}, {100., 1.37786*^-9}, {250., 7.500625*^-10}, {500., 4.754925*^-10}, {750., 3.612*^-10}, {1000., 2.94925`*^-10}}

dat1kra = {{1.`, 2.8896`*^-10}, {10.`, 7.89039`*^-11}, {50.`, 
2.403665`*^-11}, {75.`, 1.8478`*^-11}, {100.`, 
1.53523`*^-11}, {250.`, 8.33675`*^-12}, {500.`, 
5.24605`*^-12}, {750.`, 3.95007`*^-12}, {1000.`, 3.19502`*^-12}}



pltkra2part = 
       ListLogLogPlot[ dat1kra, 
       PlotRange -> {{10^0, 10^3}, {10^-12, 10^-6}}, 
       Ticks -> {Table[{10^i, 10^Defer[Evaluate[i]]}, {i, 0, 3}], 
       Table[{10^i, 10^Defer[Evaluate[i]]}, {i, -12, -6}]} , 
       Joined -> True, PlotStyle -> {Blue, Thickness[0.006], Line} , 
       FrameStyle -> Thickness[0.002], FrameTicks -> Automatic, 
       FrameTicksStyle -> Directive[Thickness[0.01], Black, 14], 
       PlotLegends -> {Style["KRA, |b| > 20 Degree, with cuts on r and 
       z", Bold, 12]} ,FrameLabel -> {Style["Energy (GeV)", Bold, 15],
        Style["Flux (GeV \!\(\*SuperscriptBox[\(cm\), \(-2\)]\) \
        \!\(\*SuperscriptBox[\(s\), \(-\\\ 1\)]\) \
         \!\(\*SuperscriptBox[\(sr\), \(-1\)]\))", Bold, 15]}, Frame ->
          True, 
           ImageSize -> 500 ]

  pltkra1full = 
     ListLogLogPlot[ dat1krafull, 
     PlotRange -> {{10^0, 10^3}, {10^-12, 10^-6}}, 
     Ticks -> {Table[{10^i, 10^Defer[Evaluate[i]]}, {i, 0, 3}], 
     Table[{10^i, 10^Defer[Evaluate[i]]}, {i, -12, -6}]} , 
     Joined -> True, PlotStyle -> {Red, Thickness[0.006], Dashed} , 
     FrameStyle -> Thickness[0.002], FrameTicks -> Automatic, 
     FrameTicksStyle -> Directive[Thickness[0.01], Black, 14], 
     PlotLegends -> {Style[
     "KRA, |b| > 20 Degree, without cuts on r and z", Bold, 12]} , 
      FrameLabel -> {Style["Energy (GeV)", Bold, 15], 
      Style["Flux (GeV \!\(\*SuperscriptBox[\(cm\), \(-2\)]\) \
       \!\(\*SuperscriptBox[\(s\), \(-\\\ 1\)]\) \
        \!\(\*SuperscriptBox[\(sr\), \(-1\)]\))", Bold, 15]}, Frame -> 
         True, ImageSize -> 500 ] 
Show[pltkra1full, pltkra2part]

In the above, I put my codes two plot data. The main problem is that the legends in the plots are outside the frame. But I want the legends to be within the frame o the plot at my desired place. Can anyone help me to figure this out?

$\endgroup$
1
$\begingroup$

One possible approach is to extract the plots and the legends from pltkra1full and pltkra2part (this easily done by taking Part[pltkra1full, 1] and Part[pltkra1full, 2, 1, 1], respectively for pltkra1full, and similarly for pltkra2part) and use a combination of Legended, Show and Placed as follows:

Legended[Show[First @ pltkra1full, First @ pltkra2part], 
 Placed[Column@{pltkra1full[[2, 1, 1]], pltkra2part[[2, 1, 1]]}, {.65, .85}]]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks, it is working fine $\endgroup$ – Sayan Biswas Jun 25 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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