Message Boards Message Boards

Convert code V4.1 into code V11?

Posted 6 years ago

Hi all,

I'm struggling with rewriting of some old code from mathematica V4.1....I'm using V11. I have problems with follwoing (old) commands:

ShowLegend
MultipleListPlot
LegendPosition

That's the code which I try to bring it into V11.

<< Graphics`Legend`
<< Graphics`MultipleListPlot`
a1 = 1.5; a2 = 3; a3 = 6;
X = 1000;
\[Lambda] = 0.01;
R = Range[-10.01, 10.01, 0.1];
I1[R_] := (BesselJ[1, 
      2*Pi*a1*(R/(\[Lambda]*X))]/(2*Pi*a1*(R/(\[Lambda]*X))))^2;
I2[R_] := (BesselJ[1, 
      2*Pi*a2*(R/(\[Lambda]*X))]/(2*Pi*a2*(R/(\[Lambda]*X))))^2;
I3[R_] := (BesselJ[1, 
      2*Pi*a3*(R/(\[Lambda]*X))]/(2*Pi*a3*(R/(\[Lambda]*X))))^2;


ShowLegend[
  MultipleListPlot[Transpose[{R, I1[R]}], Transpose[{R, I2[R]}], 
   Transpose[{R, I3[R]}], PlotJoined -> True, 
   DisplayFunction -> Identity, 
   PlotStyle -> {Hue[1], Hue[0.5], Hue[0.25]}, 
   AxesLabel -> {"R", "I"}, 
   PlotRange -> {{-15, 10}, {0, 0.3}}], {{{Hue[1], 
     "I1[R]"}, {Hue[0.5], "I2[R]"}, {Hue[0.25], "I3[R]"}}, 
   LegendPosition -> {1.1, -0}}];

I would be grateful for your support!

POSTED BY: Nikki Peter
2 Replies

For starters:

a1 = 1.5; a2 = 3; a3 = 6;
X = 1000;
\[Lambda] = 0.01;
R = Range[-10.01, 10.01, 0.1];
I1[R_] := (BesselJ[1, 2*Pi*a1*(R/(\[Lambda]*X))]/(2*Pi*a1*(R/(\[Lambda]*X))))^2;
I2[R_] := (BesselJ[1, 2*Pi*a2*(R/(\[Lambda]*X))]/(2*Pi*a2*(R/(\[Lambda]*X))))^2;
I3[R_] := (BesselJ[1,  2*Pi*a3*(R/(\[Lambda]*X))]/(2*Pi*a3*(R/(\[Lambda]*X))))^2;

With[{data = Transpose /@ {{R, I1[R]}, {R, I2[R]}, {R, I3[R]}}},
 ListLinePlot[data, AxesLabel -> {"R", "I"},
  PlotRange -> {{-15, 10}, {0, 0.3}}, 
  PlotLegends -> {"I1[R]", "I2[R]", "I3[R]"}]
 ]

Mathematica graphics

You can include your PlotStyle if you like (looks a bit old-school) and you can wrap the list of legend-strings with Placed to give an exact position.

POSTED BY: Patrick Scheibe
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