2
$\begingroup$

I have to plot two functions in one plot. I have added the following code to generate the graph.

Prat = 1.25;
wp = 1/(1 + Prat*Erat)
Plot1 = Plot[wp, {Erat, 0, 0.99}, 
  FrameLabel -> {{"\!\(\*SubscriptBox[\(\[Omega]\), \(p\)]\)", 
     None}, {"\[InvisiblePrefixScriptBase]\!\(\*SubscriptBox[\(\
\[Epsilon]\), \(o\)]\)/\!\(\*SubscriptBox[\(\[Epsilon]\), \(p\)]\)", 
     None}},
  ImagePadding -> 55,
  PlotStyle -> Blue, ImagePadding -> 25, 
  Frame -> {True, True, True, False},
  FrameStyle -> {Automatic, Automatic, Automatic, Automatic},
   LabelStyle -> {FontFamily -> "Cambria", 12, GrayLevel[0]}]
wo = 1/(1 + 1/Prat*1/Erat)
Plot2 = Plot[wo, {Erat, 0, 0.99}, ImagePadding -> 55,
  PlotStyle -> Red,
  Axes -> False, Frame -> {False, False, False, True}, 
  FrameTicks -> {{None, All}, {None, None}}, 
  FrameStyle -> {Automatic, Automatic, Automatic, Black},
  FrameLabel -> {{None, 
     "\!\(\*SubscriptBox[\(\[Omega]\), \(o\)]\)"}, {None, None}},
   LabelStyle -> {FontFamily -> "Cambria", 12, GrayLevel[0]}]
Overlay[{Plot1, Plot2}]
Export["weights.pdf", %]

However, I don't have an idea how to change the colour to black and white as it is required for a paper. I want one line to be solid black and another line to be dotted with legends added in the graph. I also tried the following code to generate mulitiple plot

ResourceFunction["MultipleAxesPlot"][{wp, wo}, {Erat, 0, 1}], but I think adding legend and axes labels here is tricky. Can someone help?
$\endgroup$

1 Answer 1

3
$\begingroup$

Instead of setting the PlotStyle to Blue/Red, set it to Black/{Dashed,Black:

Prat = 1.25;
wp = 1/(1 + Prat*Erat);
Plot1 = Plot[wp, {Erat, 0, 0.99}, 
   FrameLabel -> {{"\!\(\*SubscriptBox[\(\[Omega]\), \(p\)]\)", 
      None}, {"\[InvisiblePrefixScriptBase]\!\(\*SubscriptBox[\
\(\[Epsilon]\), \(o\)]\)/\!\(\*SubscriptBox[\(\[Epsilon]\), \(p\)]\)",
       None}}, ImagePadding -> 55, PlotStyle -> Black, 
   ImagePadding -> 25, Frame -> {True, True, True, False}, 
   FrameStyle -> {Automatic, Automatic, Automatic, Automatic}, 
   LabelStyle -> {FontFamily -> "Cambria", 12, GrayLevel[0]}, 
   Epilog -> {Text["Curve 1", Scaled[{0.9, 0.2}]]}];
wo = 1/(1 + 1/Prat*1/Erat);
Plot2 = Plot[wo, {Erat, 0, 0.99}, ImagePadding -> 55, 
   PlotStyle -> {Black, Dashed}, Axes -> False, 
   Frame -> {False, False, False, True}, 
   FrameTicks -> {{None, All}, {None, None}}, 
   FrameStyle -> {Automatic, Automatic, Automatic, Black}, 
   FrameLabel -> {{None, 
      "\!\(\*SubscriptBox[\(\[Omega]\), \(o\)]\)"}, {None, None}}, 
   LabelStyle -> {FontFamily -> "Cambria", 12, GrayLevel[0]}, 
   Epilog -> {Text["Curve 2", Scaled[{0.9, 0.8}]]}];
Overlay[{Plot1, Plot2}]

![enter image description here

$\endgroup$
2
  • $\begingroup$ But, how to add legend to the plot showing which line shows what? $\endgroup$
    – P Initiate
    Commented May 24, 2023 at 9:14
  • $\begingroup$ You may use "Epilog". I added this to my answer. $\endgroup$ Commented May 24, 2023 at 10:32

Your Answer

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

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