I think you are on the right track. You just can’t see it very well due to the fact that your y is pretty plain. Try changing the line:
float y = sin(angle)*factor;
to
float y = sin(2*angle)*factor;
You will have what you are looking for. Also, the graph will only connect the start and end depending on if the modulation of the radius and y has the same phase.
@kfrajer has a much better example in the link that he posted.