Plot discontinuous function 2−x|x−2|(x+2)\frac{2-x}{|x-2|}(x + 2) [duplicate]

This question already has an answer here:

Plot a piecewise function with black and white disks marking discontinuities

3 answers

I’d like to ask you about the way to plot discontinuous function 2−x|x−2|(x+2)\frac{2-x}{|x-2|}(x + 2).

What Wolfram Alpha produces:

“DIY” version is below. How to achieve similar effect in Mathematica?

=================

=================

1 Answer
1

=================

Use Exclusions and Epilog.

Plot[(2 – x) (x + 2)/Abs[x – 2], {x, 0, 4},
Exclusions -> {2},
Epilog -> {Red, Text[â—‹, #] & /@ {{2, 4}, {2, -4}}}]

or

Plot[f[x], {x, 0, 4},
Exclusions -> {2},
Epilog -> {Red, Text[â—‹, #] & /@ {
{2, Limit[f[x], x -> 2, Direction -> 1]},
{2, Limit[f[x], x -> 2, Direction -> -1]}}}]