分段函式圖形繪製

混沌武士丞發表於2024-06-05

import matplotlib.pyplot as plt

import numpy as np

x = np.arange(-2, 2, 0.0001)

y1 = np.sqrt(2 * np.sqrt(x ** 2) - x ** 2)

y2 = (-2.14) * np.sqrt(np.sqrt(2) - np.sqrt(np.abs(x)))

plt.plot(x, y1, 'r', x, y2, 'r')

plt.fill_between(x, y1, y2, facecolor='red')

plt.savefig("heart.png")

plt.show()

![image.png]({PTA_URL}/api/private-image?p=user-uploads/1566653959899246592/2024-6-5/1717546157-8fd640b2-6922-4282-afba-c73c6c351742.png)

相關文章