During the day, plants carry out photosynthesis releasing carbon dioxide. During the night, there isn't any sunlight so the plants carry out cellular respiration releasing oxygen.
Savannah is the answer you are looking for here.
That their ancestors were related