I am trying to plot two different functions into a single plot. Each function depends on R
and r
. I plot against r
for different R
's. So I end up with two different functions for all the different values of R
. I use SwatchLegend
to plot the legends of the different values of R
. However, I also want to plot another legend that shows which dashing I am using for each function. Such that the final plot clearly shows which values I am using of R
and that it is clear which dashing is of each function.
My synthesized code is:
First, I define the functions that I am using as
CYLINDER1[R_, r_] :=
E^(-((2.789371726903078` BesselK[0, 0.010765343149384599` r])/
BesselK[1, 0.010765343149384599` (2.125` + R)]));
SPHERE1[R_, r_] :=
E^(-((3.002854381130314`*^8 E^(
0.010765343149384599` (2.125` - r + R)) (2.125` + R))/(
r (1.0765343149384598`*^8 + 10000000000/(2.125` + R)))));
Afterwards, I defined the values of R
that I will vary, as well as the command that I will use to call the legends and placed them where I want. I also define some constants to create the dashing of my wish. And finally , I create a function to plot both functions.
RAD = {5, 15, 30, 80} ;
legrad[X_, Y_] :=
Placed[SwatchLegend[{"5 \[Angstrom]", "15 \[Angstrom]",
"30 \[Angstrom]", "80 \[Angstrom]"},
LabelStyle -> {FontSize -> 13}], {X, Y}];
l1 = 0.025;
l2 = 0.015;
d = 0.001;
s1 = l1/2;
s2 = l2/2;
C1g[X_, Y_, legX_, legY_] :=
Plot[Evaluate@Table[ArcSinh[CYLINDER1[R, r]], {R, RAD}], {r, 0, X},
PlotRange -> {-0.05 Y, Y}, PlotLegends -> legrad[legX, legY],
PlotStyle -> Dashing[{l1, s1, l1, s1, d, s1}]];
S1g[X_, Y_] :=
Plot[Evaluate@Table[ArcSinh[SPHERE1[R, r]], {R, RAD}], {r, 0, X},
PlotRange -> {-0.05 Y, Y},
PlotStyle -> Dashing[{l2, s2, l2, s2, d, s2}]];
Finally I merge them with
CS1g[X_, Y_, legX_, legY_] :=
Show[C1g[X, Y, legX, legY], S1g[X, Y], Frame -> True];
How and where do I add another legend to show the dashing and the functions (something like "--.-- Cylinder", "..-..- Sphere")
Furthermore, since I am already asking, if I were to change the values of RAD={}
. What can I do so I won't need to rewrite my labels?
Thanks in advance for the help.