DFT of pure sinusoidal wave
First of all, welcome to DSP SE.
What you see in the image you have linked is termed (spectral) leakage. When you are dealing with the Fourier series you deal with a periodic continuous function which is &quot;decomposed&quot; into a (possibly) infinite sum (series). Then, when you go to the Fourier transform, you have a non-periodic function (which you could possibly presume to be periodic in some interval if, for example, it starts and ends on the x-axis) which is decomposed into an infinite sum of spectral components (you have energy in every point on the spectrum).
Before moving further on, please note that this is a very brief explanation about the Fourier series and Fourier transform with a lot of details omitted and the mathematical interpretation presented here in more of a convenient way than the absolutely correct. For more information on the topic, I would strongly suggest the textbook Mathematical Methods for Engineers and Scientists 3 - Fourier Analysis, Partial Differential Equations and Variational Methods by Dr Kwong-Tin Tang (the first part of the book is relevant here).
Now, if you go from the continuous domain to the discrete domain (we will deal with the discretisation of the free variable here, which is time and not the amplitude as is the reality when you deal with digital signals) you move from the Fourier transform to the Discrete Fourier Transform (DFT). Once again, omitting the &quot;technical&quot; details, in DFT when the signal contains frequency (spectral) components that do not make an integer number of complete periods in the duration of the signal to be analysed, you end up with the phenomenon called leakage (see link above). This is due to the &quot;nature&quot; of the transform, in which the signal is assumed to be periodic. Thus, when you have spectral components that do not complete an integer number of periods in the duration of the signal, you will end up with an amplitude (for this component) other than zero at either the end or the beginning of the signal. If you try to &quot;copy and paste&quot; the signal before and after your original signal (in order to make it periodic for the purpose of the transform) you will realise that you end up with some discontinuity at the point where the original and the &quot;copy-and-pasted&quot; signal starts. In order to reconstruct this discontinuity, you have to introduce an infinite amount of spectral components, which show up as energy in frequencies around the main spectral component (in the case you only have a &quot;pure&quot; (co)sine wave). You can see an example of a single frequency in the picture below.

Now, another concept you will most probably encounter quite often (if not always!) when dealing with DFT is the term window. In the simple case where you apply no windowing function (bear with me a wee bit more for an explanation) to the signal is like applying a &quot;rectangular&quot; window where you multiply all the values of your signal with one, thus, effectively doing nothing to them.
If you apply a windowing function to your signal you effectively suppress the signal at its edges in order to avoid the appearance of discontinuities such as those visible in the second plot on the right-hand side of the image above. Thus you somehow suppress the leakage effect. Please keep in mind that the simplest way of applying a windowing function is to element-wise multiply the samples of your signal with the windowing function in the time domain.
The signal on the right-hand side of the above image after the application of a Hann window would look like in the image below

And for a &quot;clearer&quot; representation of the spectrum before and after the windowing you can see this image

You can see that the peak is not so well localised but the leakage has been constrained to a smaller &quot;neighbourhood&quot; than before. For more information on windowing and window functions, you can have a look at the Wikipedia page (link above at the word &quot;window&quot;) and any elementary Digital Signal Processing textbook such as the Digital Signal Processing - Principles Algorithms and Applications by Proakis &amp; Manolakis or Introduction to Signal Processing by Orfanidis (which is freely distributed).