How can I plot the margins of SVM in R




While studying about SVM’s I got interested in knowing how to plot the margins for the data and stumbled upon this code on stackoverflow:

However I do not understand this code.Can someone please help me understand this part with an example of a dataset like may be iris