6
$\begingroup$

This question already has an answer here:

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?

$\endgroup$

marked as duplicate by J. M. will be back soon plotting Mar 15 '18 at 1:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    $\begingroup$ ColorData[97][1] at least in version 11 $\endgroup$ – Henrik Schumacher Mar 14 '18 at 19:12
  • $\begingroup$ Here's an answer with this and more: mathematica.stackexchange.com/a/54632/38205 $\endgroup$ – b3m2a1 Mar 14 '18 at 19:44
  • $\begingroup$ You can see all the colors used, including axes, with InputForm@DeleteDuplicates@Cases[plot, _?ColorQ, Infinity]. $\endgroup$ – Michael E2 Mar 14 '18 at 19:58
5
$\begingroup$
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.

$\endgroup$
3
$\begingroup$

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

$\endgroup$

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