1
$\begingroup$

I am adding an additional tick to a plot. How can I make the new added tick (the blue number) to have less decimal numbers? It seems "WorkingPrecision" doesn't work.

gamma2 = .265; gamma1 = .484; z2 = 32000/1000; zbar2 = 46200/1000;
h4 = .301; h3 = .404; h2 = .25;
h1 = .045;
h21 = h2/(h2 + h3);
h31 = h3/(h2 + h3);
p2 = 4.92;
g2 = 0.44;

Cost4 = h21 (g2 (zbar2 - z2) - g2 a p2 zbar2 gamma2 (1/(1 - τ1)));
Gain4 = h21 ((zbar2 - z2) - zbar2 gamma2 (τ1/(1 - τ1)));


daSol = Solve[{Cost4 == Gain4}, {τ1}, WorkingPrecision -> 3] // 
    Flatten // Last;
sol[aa_] := daSol /. a -> aa
yTicksToAdd1 = {N[τ1, 2] /. sol[0.05]};


d4 = Show[
  Plot[Evaluate@Table[Cost4, {a, {0, 0.05}}], {τ1, -1, 1}], 
  Plot[Evaluate@Table[ Gain4, {a, {0.05}}], {τ1, -1, 1}, 
   PlotStyle -> Directive[Red, Dashed] ]]

NRm3 = Show[d4, 
  bzz = Ticks -> {Join[
      Last[Ticks /. 
        AbsoluteOptions[d4]], {#, Style[#, {Blue, 13}]} & /@ (N[
         yTicksToAdd1, 2])], Last[Ticks /. AbsoluteOptions[d4]]}]
$\endgroup$

2 Answers 2

1
$\begingroup$

Try This:

text = Graphics[
   Text[Style[ToString[SetPrecision[yTicksToAdd1[[1]], 2]], 15, 
     Blue], {0.6, -2}]];
Show[d4, text, PlotRange -> {{-1, 1}, {-5, 10}}]

enter image description here

$\endgroup$
1
$\begingroup$

You can use Epilog to put any extra object inside a plot.

Show[Plot[Evaluate@Table[Cost4, {a, {0, 0.05}}], {τ1, -1, 1}], 
     Plot[Evaluate@Table[Gain4, {a, {0.05}}], {τ1, -1, 1}, 
       PlotStyle -> Directive[Red, Dashed]], PlotRange -> {{-1, 1}, {-0.5, 2.5}},
     Epilog -> {Blue, PointSize[Large], Point[{yTicksToAdd1[[1]], 0.}],
                Text[NumberForm[yTicksToAdd1[[1]], 2], {yTicksToAdd1[[1]] + 0.1, 0.}]}]

enter image description here

You can use Style to change the appearance of your text.

$\endgroup$

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.