I'm trying to fill the common interior of circle and cardioid in polar coordinates (r1= sqrt(3)* sin(φ) and r2= 1 - cos(φ)). I've found a simple solution in this question — find the minimum of two functions and fill an area between 0 and minimum. Code:
import matplotlib.pyplot as plt
import numpy as np
import math
phi = np.arange(0, (2 * np.pi), 0.01)
r1 = math.sqrt(3) * np.sin(phi)
r2 = 1 - np.cos(phi)
r3 = np.minimum(r1, r2)
plt.polar(phi, r1)
plt.polar(phi, r2)
plt.fill_between(phi, 0, r3, color='#D0D0FF')
plt.show()
But the end result is strange. The bottom part, where φ goes from 2π to 0, is 'inverted'.
Perhaps I don't understand the 'where' argument of 'fill_between'. Any ideas?
