2

I am facing an issue when trying to use Show command to show multiple graphs within one graph. Show command only shows red dot from one of the graph.

u3b = Plot[f1[a, x], {x, -10, 20}, PlotStyle -> Blue, 
  AxesLabel -> {"x", "y"}, 
  Epilog -> {PointSize[Large], Red, 
    Point[{x, 0} /. NSolve[f1[a, x]]]}]

first graph with red dot

dydx = D[x^3 - a x^2 - x + 1, x];

Plot[dydx, {x, -10, 20}, PlotStyle -> Blue, AxesLabel -> {"x", "y"}]
u3c = Plot[dydx, {x, -10, 20}, PlotRange -> Automatic, 
  PlotStyle -> Blue, AxesLabel -> {"x", "y"}, 
  Epilog -> {PointSize[Large], Red, Point[{x, 0} /. NSolve[dydx]]}]

Show[u3b, u3c, PlotRange -> Automatic]

second graph with red dot and Show command that left the red dot out

Onizuka
  • 349
  • 1
  • 2
  • 8

1 Answers1

3

For example:

f1[a_, x_] := x^3 - a x^2 - x + 1
a = 4;
epilog1 = {PointSize[Large], Red, Point[{x, 0} /. NSolve[f1[a, x]]]};
epilog2 = {PointSize[Large], Green, Point[{x, 0} /. NSolve[D[f1[a, x], x]]]};

u3b = Plot[f1[a, x], {x, -10, 20}, AxesLabel -> {"x", "y"}];
u3c = Plot[D[f1[a, t], t] /. t -> x, {x, -10, 20}];

Show[u3b, u3c, Epilog -> Join[epilog1, epilog2]]

Mathematica graphics

There are in fact a lot of ways to achieve the same result. Another example is:

Show[u3b, u3c, Graphics@Join[epilog1, epilog2]]

The most common problem is that Show[] takes its plot range from the first argument, so you need to be careful about setting it right.

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453