9

My code is a simple function which I plot for two different times t

up[x_, t_] := un*Exp[I*((kr + I*ki)*x - (wr + I*wi)*t)];

un = 1;
kr = 2*Pi;
ki = 0.1;
wr = 0.1;
wi = 0.1;

a0 = Show[
  Plot[Re[up[x, 1]], {x, 0, 10}, PlotRange -> All, 
   AxesLabel -> {Style["x", FontSize -> 13], 
     Style["q'", FontSize -> 13]}, 
   PlotLegends -> 
    PointLegend[{Blue}, {"\!\(\*SubscriptBox[\(t\), \(0\)]\)"}]], 
  Plot[Re[up[x, 5]], {x, 0, 10}, PlotRange -> All, 
   AxesLabel -> {Style["x", FontSize -> 13], 
     Style["q'", FontSize -> 13]}, PlotStyle -> Orange, 
   PlotLegends -> 
    PointLegend[{Orange}, {"\!\(\*SubscriptBox[\(t\), \
\(1\)]\)>\!\(\*SubscriptBox[\(t\), \(0\)]\)"}]]]

enter image description here

How to set the same blue tone from Plot (default) to the legend label?

kglr
  • 394,356
  • 18
  • 477
  • 896
Mateus
  • 1,243
  • 7
  • 14

2 Answers2

5
Plot[{Re[up[x, 1]],Re[up[x, 5]] }, {x, 0, 10}, PlotRange -> All, 
   AxesLabel -> {Style["x", FontSize -> 13],  Style["q'", FontSize -> 13]}, 
   PlotLegends -> PointLegend[Automatic,{Subscript[t,0]  ,Subscript[t,1]>Subscript[t,0]}]]

enter image description here

Using ColorData[97,"ColorList"][[;;2]] in place of Automatic gives the same result.

kglr
  • 394,356
  • 18
  • 477
  • 896
3

If you do not specify a color, the legend will get it from the plot:

a0 = Show[
  Plot[Re[up[x, 1]], {x, 0, 10}, PlotRange -> All, 
   AxesLabel -> {Style["x", FontSize -> 13], 
     Style["q'", FontSize -> 13]},
   PlotLegends -> PointLegend[{"\!\(\*SubscriptBox[\(t\), \(0\)]\)"}]],
  Plot[Re[up[x, 5]], {x, 0, 10}, PlotRange -> All, 
   AxesLabel -> {Style["x", FontSize -> 13], 
     Style["q'", FontSize -> 13]}, PlotStyle -> Orange,
   PlotLegends -> 
    PointLegend[{"\!\(\*SubscriptBox[\(t\), \(1\)]\)>\!\(\*SubscriptBox[\(t\), \(0\)]\)"}]]]

Mathematica graphics

Michael E2
  • 235,386
  • 17
  • 334
  • 747