-5
$\begingroup$
p6 = Plot[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(50\)]\(
\*FractionBox[\(1\), \(\((2*\ k + 1)\)*\ \[Pi]\)] 4\ *1 (*c0*) *
     MittagLefflerE[0.5 (*\[Beta]*) , \((\(-0.1\) (*D*) *\ 
\*SuperscriptBox[\((2\ *k + 1)\), \(2\)]\ *
\*SuperscriptBox[\(\[Pi]\), \(2\)]\ *
\*SuperscriptBox[\(t\), \(\(0.5\)\( (*\[Beta]*) \)\)])\)]\ *
     Sin[\((2\ *k + 1)\)*\ \[Pi]*\ 0.5 (*x*) ]\)\), {t, 0, 10}];
p7 = Plot[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(50\)]\(\((
\*FractionBox[\(4*1 (*c0*) *
\*SuperscriptBox[\(E\), \((\(-0.002\) (*D*) *
\*SuperscriptBox[\((2*k + 1)\), \(2\)]*
\*SuperscriptBox[\(\[Pi]\), \(2\)]*t)\)]\), \(\((2*k + 
          1)\)*\[Pi]\)])\)*Sin[\((2*k + 1)\)*\[Pi]*0.5]\)\), {t, 0, 
    10}];
p8 = Plot[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(50\)]\(\((
\*FractionBox[\(4*1 (*c0*) *
\*SuperscriptBox[\(E\), \((\(-0.0025\) (*D*) *
\*SuperscriptBox[\((2*k + 1)\), \(2\)]*
\*SuperscriptBox[\(\[Pi]\), \(2\)]*t)\)]\), \(\((2*k + 
          1)\)*\[Pi]\)])\)*Sin[\((2*k + 1)\)*\[Pi]*0.5]\)\), {t, 0, 
    10}];
p9 = Plot[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(50\)]\(\((
\*FractionBox[\(4*1 (*c0*) *
\*SuperscriptBox[\(E\), \((\(-0.003\) (*D*) *
\*SuperscriptBox[\((2*k + 1)\), \(2\)]*
\*SuperscriptBox[\(\[Pi]\), \(2\)]*t)\)]\), \(\((2*k + 
          1)\)*\[Pi]\)])\)*Sin[\((2*k + 1)\)*\[Pi]*0.5]\)\), {t, 0, 
    10}];
p10 = Plot[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(50\)]\(\((
\*FractionBox[\(4*1 (*c0*) *
\*SuperscriptBox[\(E\), \((\(-0.0035\) (*D*) *
\*SuperscriptBox[\((2*k + 1)\), \(2\)]*
\*SuperscriptBox[\(\[Pi]\), \(2\)]*t)\)]\), \(\((2*k + 
          1)\)*\[Pi]\)])\)*Sin[\((2*k + 1)\)*\[Pi]*0.5]\)\), {t, 0, 
    10}];
p11 = Plot[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(50\)]\(\((
\*FractionBox[\(4*1 (*c0*) *
\*SuperscriptBox[\(E\), \((\(-0.004\) (*D*) *
\*SuperscriptBox[\((2*k + 1)\), \(2\)]*
\*SuperscriptBox[\(\[Pi]\), \(2\)]*t)\)]\), \(\((2*k + 
          1)\)*\[Pi]\)])\)*Sin[\((2*k + 1)\)*\[Pi]*0.5]\)\), {t, 0, 
    10}];
Show[p6, p7, p8, p9, p10, p11, PlotLegends -> "Expressions", AxesOrigin -> {0, 0}]

I would like to combine the above plots using theShow command. However, only one curve appears in the output.

enter image description here

Furthermore, no legend is visible. What is the problem?

$\endgroup$
4
  • $\begingroup$ Add PlotRange -> All to your Show expression. In Show the PlotRange settings are inherited from the first plot in the list, and that choice just happens to cut out all other plots. Show[p6, p7, p8, p9, p10, p11, PlotRange -> All, AxesOrigin -> {0, 0}] $\endgroup$
    – MarcoB
    May 23 at 16:05
  • 4
    $\begingroup$ Please take a look at How to copy code from Mathematica so it looks good on this site so you can past readable code in your future questions. $\endgroup$
    – MarcoB
    May 23 at 16:06
  • 1
    $\begingroup$ Code like this is unreadable. You should know that by not taking care of sharing reasonably formatted code in InputForm, you are alienating many experienced people that could otherwise help find a good answer. $\endgroup$
    – rhermans
    May 23 at 16:59
  • $\begingroup$ @MarcoB,your link helps me better format my code. $\endgroup$
    – Stan
    May 24 at 6:36

2 Answers 2

5
$\begingroup$
Clear["Global`*"]

Define separate functions rather than separate plots.

f[1] = Sum[(1/((2*k + 1)*Pi))*4*1*MittagLefflerE[0.5, 
           -0.1*(2*k + 1)^2*Pi^2*t^0.5]*Sin[(2*k + 1)*
             Pi*0.5], {k, 0, 50}]; 

f[2] = Sum[((4*1)/(E^(0.002*(2*k + 1)^2*Pi^2*t)*((2*k + 1)*
                  Pi)))*Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}]; 

f[3] = Sum[((4*1)/(E^(0.0025*(2*k + 1)^2*Pi^2*t)*((2*k + 1)*
                  Pi)))*Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}]; 

f[4] = Sum[((4*1)/(E^(0.003*(2*k + 1)^2*Pi^2*t)*((2*k + 1)*
                  Pi)))*Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}]; 

f[5] = Sum[((4*1)/(E^(0.0035*(2*k + 1)^2*Pi^2*t)*((2*k + 1)*
                  Pi)))*Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}]; 

f[6] = Sum[((4*1)/(E^(0.004*(2*k + 1)^2*Pi^2*t)*((2*k + 1)*
                  Pi)))*Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}]; 

Use a single Plot. For comparison I use both PlotLabels and PlotLegends, you would most likely only use one or the other.

Plot[Evaluate[f /@ Range[6]], {t, 0, 10},
 PlotStyle -> {Automatic, Dashed},
 PlotRange -> All,
 PlotLabels -> (Subscript[f, #] & /@ Range[6]),
 PlotLegends -> (Subscript[f, #] & /@ Range[6])]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks Bob. your logical, specific code helps me a lot. I want to mark the plot-Labels inside the picture frame, and I try some options which doesn't work. $\endgroup$
    – Stan
    May 24 at 6:44
5
$\begingroup$
f6 = Sum[(1/((2*k + 1)*Pi))*4*1*
         MittagLefflerE[0.5, -0.1*(2*k + 1)^2*
             Pi^2*t^0.5]*Sin[(2*k + 1)*Pi*0.5], 
       {k, 0, 50}]; 
f7 = Sum[((4*1)/(E^(0.002*(2*k + 1)^2*Pi^2*
                    t)*((2*k + 1)*Pi)))*
         Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}]; 
f8 = Sum[((4*1)/(E^(0.0025*(2*k + 1)^2*Pi^2*
                    t)*((2*k + 1)*Pi)))*
         Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}]; 
f9 = Sum[((4*1)/(E^(0.003*(2*k + 1)^2*Pi^2*
                    t)*((2*k + 1)*Pi)))*
         Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}]; 
f10 = Sum[((4*1)/(E^(0.0035*(2*k + 1)^2*
                    Pi^2*t)*((2*k + 1)*Pi)))*
         Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}]; 
f11 = Sum[((4*1)/(E^(0.004*(2*k + 1)^2*Pi^2*
                    t)*((2*k + 1)*Pi)))*
         Sin[(2*k + 1)*Pi*0.5], {k, 0, 50}];
Plot[Evaluate@{f6, f7, f8, f9, f10, f11}, {t, 0, 10}, 
 PlotRange -> Full, AxesOrigin ->  {0, 0}
 , PlotLegends -> {
   Placed[
    LineLegend[ColorData[97][#] & /@ Range[2, 6]~Join~{1}, 
     "f" <> ToString@# & /@ Range[7, 11]~Join~{6}
     ]
    , After]
   }
 ]

enter image description here


EDIT-II

If you want to put the legend inside the picture, and experiment with "Row", "Column", their count and position then you can modify the following. Here I have put the legend just to the right (1.05) of plot and half way on the vertical scale (0.55).

PlotLegends -> {
  Placed[LineLegend[ColorData[97][#] & /@ Range[2, 6]~Join~{1}, 
    "f" <> ToString@# & /@ Range[7, 11]~Join~{6}
    , LegendLayout -> {"Column", 1}
    ]
   , {1.05, 0.55}]
  }
$\endgroup$
2
  • 4
    $\begingroup$ Code like this is unreadable. $\endgroup$
    – rhermans
    May 23 at 17:00
  • $\begingroup$ Thanks Syed. the code for legend is a tough work. $\endgroup$
    – Stan
    May 24 at 6:46

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.