A density is just like any other function. To plot it, simply draw $f(x) = \frac{1}{2}$ on the given interval $[0,2]$. This would be a zero slope line at $\frac{1}{2}$ on the vertical axis from $0$ to $2$ on the horizontal axis (including $0$ and $2$, obviously). Note that the vertical axis is the probability for a given element in the domain of the random variable whose density function we are considering. This is the density of a uniform random variable on $[0,2]$.
A density is just like any other function. To plot it, simply draw $f(x) = \frac{1}{2}$ on the given interval $[0,2]$. This would be a zero slope line at $\frac{1}{2}$ on the vertical axis from $0$ to $2$ on the horizontal axis (including $0$ and $2$, obviously). Note that the vertical axis is the probability for a given element in the domain of the random variable whose density function we are considering. This is the density of a uniform random variable on $[0,2]$.