I would like to obtain a graph of the potential energy of a polygon under rotation, given that it is proportional to the vertical distance from the centroid to the "floor". I have made the following attempts: given the polygon

i have obtained the graph below

(ignore the bottom part and the angles). Of course, I should expect a continuous curve, but I'm not getting one... I've obtained this curve using calculations. Any help?
I finally managed to solve the problem. The curve above is completely wrong. The idea the solution is that the potential energy of the curve depends on the vertical distance of the centroid to the "floor", and since the centroid rotates around a vertex, it describes a circular motion. Hence it is a curve of the form $a\sin(bx+c)$ and we just need to plug in known values to find the parameters. The resulting curve (much nicer) is the following:
Where the angular speed with respect to the center of mass has been kept constant.