使用Python进行函数作画 - 指南
前言
因为之前通过deepseek绘制一下卡通的人物根本就不像,又想起来之前又大佬通过函数绘制了一些图像,想着能不能用Python来实现,结果发现可以,不过一些细节还是需要自己调整,deepseek整体的框架是没有问题,只有线条的颜色以及部分函数实现失败了,需要自己理解一下再调整绘制。
WalkingStar的个人空间-WalkingStar个人主页-哔哩哔哩视频
数学魔法!!980个初等函数画芙莉莲&勇者_哔哩哔哩_bilibili
鸡函数
先来个简单的吧,这个确实非常的耗时间,这个是我按照UP主视频一个个敲的,很考验耐心,更别说UP主是先导入图片,然后根据线条一点一点拟合图形,整个过程纯手工拟合,没用任何外置插件以及内置几何工具,后续的图形就是在UP主公开的图形中进行修改。
整个代码的制作步骤,因为deepseek无法识别链接,使用我是通过记事本粘贴网站中所有的函数,然后用deepseek生成Python代码,整个过程一个是颜色会有问题,还有就是有些函数无法显示,需要通过结合desmos网站进行对比调整。
函数
\frac{x^{2}}{16}+\frac{y^{2}}{4}=1\frac{x^{2}}{16}+y^{2}=1\left\{y\le0\right\}\left(x-3\right)^{2}+\left(y-4.6\right)^{2}=9\left(x+3\right)^{2}+\left(y-4.6\right)^{2}=9\left(x-4\right)^{2}+\left(y-5\right)^{2}\le0.5\left(x+2\right)^{2}+\left(y-5\right)^{2}\le0.5\frac{\left(x+2.5\right)^{2}}{140}+\frac{\left(y-3\right)^{2}}{81}=1\left\{y\ge3\right\}\frac{\left(0.174\left(x-7\right)+0.985y\right)^{2}}{4.5}+\frac{\left(0.174y-0.985\left(x-7\right)\right)^{2}}{2}\le1\frac{\left(0.707\left(x+9\right)+0.702\left(y-1\right)\right)^{2}}{6.5}+\frac{\left(0.707\left(y-1\right)-0.707\left(x+9\right)\right)^{2}}{8.5}\le1y+2.8=0.5\sin0.3\left(x+11.36\right)\left\{-14\le x\le9\right\}y=-1.5\left(x+14\right)-3.156\left\{-14\le x\le-12.5\right\}x-9.25=0.6\sin\left(y+3.1\right)\left\{-6.5\le x\le-2.5\right\}y=-5.7\left\{-12\le x\le8\right\}\left(y+10\right)^{2}=80\left(x+12.8\right)\left\{-10\le y\le-5.36\right\}\left(y+10\right)^{2}=-50\left(x-9.7\right)\left\{-10\le y\le-6.5\right\}y+1=-0.15x\left\{7.259\le x\le9.6\right\}y=6.5\left(x+15\right)\left\{-14.286\le x\le-13.5\right\}y-7.5=0.2x\left\{-14.286\le x\le-10.68\right\}y=6.5\left(x+11.5\right)\left\{-10.849\le x\le-9.964\right\}y-6.4=0.2x\left\{-10.85\le x\le-7.2\right\}y=6.5\left(x+8\right)\left\{-7.238\le x\le-6.9\right\}y-8.5=0.2x\left\{-6.905\le x\le-5\right\}y=-1.5x\left\{-5.3\le x\le-4\right\}\left(y-6\right)^{2}=60\left(x+4\right)\left\{6\le y\le13.5\right\}y-11.5=0.05x\left\{-3.528\le x\le1.5\right\}y-11.425=2\left(x+1.5\right)\left\{-1.5\le x\le-0.3\right\}y-13.825=-0.4\left(x+0.8\right)^{2}\left\{-0.342\le x\le3.4\right\}y-7=-0.1x\left\{3.4\le x\le6.5\right\}y=-2.5\left(x-9.3\right)\left\{5.427\le x\le6.9\right\}y-10.8=-0.7x\left\{6.9\le x\le8.5\right\}y=3\left(x-7\right)\left\{8.6\le x\le9.5\right\}y=-1.7\left(x-14\right)\left\{7.5\le x\le9.5\right\}y-5=-0.1x\left\{-16\le x\le-14\right\}y=4\left(x+17.5\right)\left\{-15.854\le x\le-15\right\}y-16=-0.025x^{2}\left\{-15.5\le x\le-5\right\}y-13.6=-0.35\left\{-5\le x\le-2\right\}y=x+16\left\{-1.8\le x\le0\right\}y-16.4=-0.05\left(x+2.7\right)^{2}\left\{0\le x\le7.7\right\}y+7.5=0.2x\left\{0.455\le x\le8\right\}y+8.3=-0.2x\left\{-12\le x\le-1\right\}y+7.35=-0.13x\left\{-12\le x\le0.455\right\}y+8.45=0.3x\left\{0.6\le x\le8\right\}y+7.6=0.5x\left\{-2\le x\le-1\right\}x=-2\left\{-10.5\le x\le-8.6\right\}y=-10.5\left\{-2\le x\le0.75\right\}y+7.8=-\left(x+0.2\right)^{2}\left\{0.5\le x\le0.83\right\}x=0.83\left\{-10.5\le y\le-8.861\right\}\left(0.5\left(x+18\right)+0.866\left(y+3\right)\right)^{2}+\left(0.5\left(y+3\right)-0.866\left(x+18\right)\right)^{2}=64\left\{0.5\left(y+3\right)-0.866\left(x+18\right)\ge0\right\}0.423\left(y+16\right)-0.906\left(x+10\right)=\frac{200}{0.423\left(x+10\right)+0.906\left(y+16\right)}\left\{0.423\left(x+10\right)+0.906\left(y+16\right)>0\right\}\left\{-24.5\le x\le-14\right\}0.866\left(y-30\right)-0.5\left(x+4\right)=\frac{600}{0.866\left(x+4\right)+0.5\left(y-30\right)}\left\{0.866\left(x+4\right)+0.5\left(y-30\right)\le0\right\}\left\{-26\le x\le-14\right\}y+5.1=-0.04\left(x+25.7\right)^{2}\left\{-25.7\le x\le-14.8\right\}y=\frac{70}{x}\left\{-12.15\le x\le-6\right\}y=\frac{50}{x+4}\left\{-12.3\le x\le-8.2\right\}y=-\frac{70}{x+3.3}\left\{2.5\le x\le8.15\right\}y=-\frac{50}{x}\left\{4\le x\le8.15\right\}
代码
import numpy as npimport matplotlib.pyplot as pltfrom matplotlib.patches import Circle # 设置图形大小plt.figure(figsize=(16, 12))ax = plt.gca() # 设置坐标轴范围ax.set_xlim(-30, 20)ax.set_ylim(-15, 30)ax.spines['bottom'].set_position(('data', 0)) # 强制x轴显示在y=0位置ax.spines['left'].set_position(('data', 0)) # 强制y轴显示在x=0位置ax.set_aspect('equal')ax.grid(True, linestyle='--', alpha=0.7)plt.title('Chicken function', fontsize=18, pad=12, weight='bold') # 加粗标题 # 1. 椭圆: x²/16 + y²/4 = 1theta = np.linspace(0, 2 * np.pi, 500)x1 = 4 * np.cos(theta)y1 = 2 * np.sin(theta)plt.plot(x1, y1, 'b-', linewidth=1.5) # 2. 半椭圆: x²/16 + y² = 1 (y ≤ 0)y2 = -np.sqrt(1 - x1 ** 2 / 16)plt.plot(x1, y2, 'b-', linewidth=1.5) # 3-4. 两个圆: (x±3)² + (y-4.6)² = 9circle1 = Circle((3, 4.6), 3, fill=False, edgecolor='b', linewidth=1.5)circle2 = Circle((-3, 4.6), 3, fill=False, edgecolor='b', linewidth=1.5)ax.add_patch(circle1)ax.add_patch(circle2) # 5-6. 实心圆: (x-4)² + (y-5)² ≤ 0.5 和 (x+2)² + (y-5)² ≤ 0.5solid_circle1 = Circle((4, 5), np.sqrt(0.5), color='r', alpha=0.5)solid_circle2 = Circle((-2, 5), np.sqrt(0.5), color='r', alpha=0.5)ax.add_patch(solid_circle1)ax.add_patch(solid_circle2) # 7. 椭圆弧: (x+2.5)²/140 + (y-3)²/81 = 1 (y ≥ 3)x7 = np.linspace(-2.5 - 11.8, -2.5 + 11.8, 500)y7_upper = 3 + 9 * np.sqrt(1 - (x7 + 2.5) ** 2 / 140)# 'g-' → 'b-':将颜色标识符从绿色(green)改为蓝色(blue)plt.plot(x7, y7_upper, 'b-', linewidth=1.5) # 8. 旋转椭圆区域: (0.174(x-7)+0.985y)²/4.5 + (0.174y-0.985(x-7))²/2 ≤ 1def rotated_ellipse(x, y): u = 0.174 * (x - 7) + 0.985 * y v = 0.174 * y - 0.985 * (x - 7) return u ** 2 / 4.5 + v ** 2 / 2 x8, y8 = np.meshgrid(np.linspace(3, 11, 400), np.linspace(-5, 5, 400))z8 = rotated_ellipse(x8, y8)# purple->redplt.contourf(x8, y8, z8, levels=[0, 1], colors=['red'], alpha=0.3) # 9. 另一个旋转椭圆区域 def rotated_ellipse2(x, y): u = 0.707 * (x + 9) + 0.702 * (y - 1) v = 0.707 * (y - 1) - 0.707 * (x + 9) return u ** 2 / 6.5 + v ** 2 / 8.5 x9, y9 = np.meshgrid(np.linspace(-16, -2, 400), np.linspace(-5, 7, 400))z9 = rotated_ellipse2(x9, y9)# orange->redplt.contourf(x9, y9, z9, levels=[0, 1], colors=['red'], alpha=0.3) # 10. 正弦波: y+2.8 = 0.5*sin(0.3(x+11.36)) [-14 ≤ x ≤ 9]x10 = np.linspace(-14, 9, 500)y10 = -2.8 + 0.5 * np.sin(0.3 * (x10 + 11.36))plt.plot(x10, y10, 'b-', linewidth=1.5) # 11. 直线段: y = -1.5(x+14)-3.156 [-14 ≤ x ≤ -12.5]x11 = np.linspace(-14, -12.5, 100)y11 = -1.5 * (x11 + 14) - 3.156plt.plot(x11, y11, 'b-', linewidth=1.5) # 12. 正弦波: x-9.25 = 0.6*sin(y+3.1) [-6.5 ≤ y ≤ -2.5]y12 = np.linspace(-6.5, -2.5, 500)x12 = 9.25 + 0.6 * np.sin(y12 + 3.1)plt.plot(x12, y12, 'b-', linewidth=1.5) # 13. 水平线: y = -5.7 [-12 ≤ x ≤ 8]x13 = np.linspace(-12, 8, 100)y13 = np.full_like(x13, -5.7)plt.plot(x13, y13, 'b-', linewidth=1.5) # 14. 抛物线: (y+10)² = 80(x+12.8) [-10 ≤ y ≤ -5.36]y14 = np.linspace(-10, -5.36, 500)x14 = (y14 + 10) ** 2 / 80 - 12.8plt.plot(x14, y14, 'b-', linewidth=1.5) # 15. 抛物线: (y+10)² = -50(x-9.7) [-10 ≤ y ≤ -6.5]y15 = np.linspace(-10, -6.5, 500)x15 = 9.7 - (y15 + 10) ** 2 / 50plt.plot(x15, y15, 'b-', linewidth=1.5) # 16. 直线段: y+1 = -0.15x [7.259 ≤ x ≤ 9.6]x16 = np.linspace(7.259, 9.6, 100)y16 = -0.15 * x16 - 1plt.plot(x16, y16, 'b-', linewidth=1.5) # 17-20. 多段直线x17 = np.linspace(-14.286, -13.5, 100)y17 = 6.5 * (x17 + 15)plt.plot(x17, y17, 'g-', linewidth=1.5) x18 = np.linspace(-14.286, -10.68, 100)y18 = 0.2 * x18 + 7.5plt.plot(x18, y18, 'g-', linewidth=1.5) x19 = np.linspace(-10.849, -9.964, 100)y19 = 6.5 * (x19 + 11.5)plt.plot(x19, y19, 'g-', linewidth=1.5) x20 = np.linspace(-10.85, -7.2, 100)y20 = 0.2 * x20 + 6.4plt.plot(x20, y20, 'g-', linewidth=1.5) # 21-22. 更多直线段x21 = np.linspace(-7.238, -6.9, 100)y21 = 6.5 * (x21 + 8)plt.plot(x21, y21, 'g-', linewidth=1.5) x22 = np.linspace(-6.905, -5, 100)y22 = 0.2 * x22 + 8.5plt.plot(x22, y22, 'g-', linewidth=1.5) # 23. 直线段: y = -1.5x [-5.3 ≤ x ≤ -4]x23 = np.linspace(-5.3, -4, 100)y23 = -1.5 * x23plt.plot(x23, y23, 'g-', linewidth=1.5) # 24. 抛物线: (y-6)² = 60(x+4) [6 ≤ y ≤ 13.5]y24 = np.linspace(6, 13.5, 500)x24 = (y24 - 6) ** 2 / 60 - 4plt.plot(x24, y24, 'g-', linewidth=1.5) # 25. 直线段: y-11.5 = 0.05x [-3.528 ≤ x ≤ 1.5]x25 = np.linspace(-3.528, 1.5, 100)y25 = 0.05 * x25 + 11.5plt.plot(x25, y25, 'g-', linewidth=1.5) # 26. 直线段: y-11.425 = 2(x+1.5) [-1.5 ≤ x ≤ -0.3]x26 = np.linspace(-1.5, -0.3, 100)y26 = 2 * (x26 + 1.5) + 11.425plt.plot(x26, y26, 'g-', linewidth=1.5) # 27. 抛物线: y-13.825 = -0.4(x+0.8)² [-0.342 ≤ x ≤ 3.4]x27 = np.linspace(-0.342, 3.4, 500)y27 = -0.4 * (x27 + 0.8) ** 2 + 13.825plt.plot(x27, y27, 'g-', linewidth=1.5) # 28. 直线段: y-7 = -0.1x [3.4 ≤ x ≤ 6.5]x28 = np.linspace(3.4, 6.5, 100)y28 = -0.1 * x28 + 7plt.plot(x28, y28, 'g-', linewidth=1.5) # 29. 直线段: y = -2.5(x-9.3) [5.427 ≤ x ≤ 6.9]x29 = np.linspace(5.427, 6.9, 100)y29 = -2.5 * (x29 - 9.3)plt.plot(x29, y29, 'g-', linewidth=1.5) # 30. 直线段: y-10.8 = -0.7x [6.9 ≤ x ≤ 8.5]x30 = np.linspace(6.9, 8.5, 100)y30 = -0.7 * x30 + 10.8plt.plot(x30, y30, 'g-', linewidth=1.5) # 31. 直线段: y = 3(x-7) [8.6 ≤ x ≤ 9.5]x31 = np.linspace(8.6, 9.5, 100)y31 = 3 * (x31 - 7)plt.plot(x31, y31, 'g-', linewidth=1.5) # 32. 直线段: y = -1.7(x-14) [7.5 ≤ x ≤ 9.5]x32 = np.linspace(7.5, 9.5, 100)y32 = -1.7 * (x32 - 14)plt.plot(x32, y32, 'g-', linewidth=1.5) # 33. 直线段: y-5 = -0.1x [-16 ≤ x ≤ -14]x33 = np.linspace(-16, -14, 100)y33 = -0.1 * x33 + 5plt.plot(x33, y33, 'g-', linewidth=1.5) # 34. 直线段: y = 4(x+17.5) [-15.854 ≤ x ≤ -15]x34 = np.linspace(-15.854, -15, 100)y34 = 4 * (x34 + 17.5)plt.plot(x34, y34, 'g-', linewidth=1.5) # 35. 抛物线: y-16 = -0.025x² [-15.5 ≤ x ≤ -5]x35 = np.linspace(-15.5, -5, 500)y35 = -0.025 * x35 ** 2 + 16plt.plot(x35, y35, 'g-', linewidth=1.5) # 36. 水平线: y-13.6 = -0.35 [-5 ≤ x ≤ -2]x36 = np.linspace(-5, -2, 100)y36 = np.full_like(x36, 13.6 - 0.35)plt.plot(x36, y36, 'g-', linewidth=1.5) # 37. 直线段: y = x+16 [-1.8 ≤ x ≤ 0]x37 = np.linspace(-1.8, 0, 100)y37 = x37 + 16plt.plot(x37, y37, 'g-', linewidth=1.5) # 38. 抛物线: y-16.4 = -0.05(x+2.7)² [0 ≤ x ≤ 7.7]x38 = np.linspace(0, 7.7, 500)y38 = -0.05 * (x38 + 2.7) ** 2 + 16.4plt.plot(x38, y38, 'g-', linewidth=1.5) # 39. 直线段: y+7.5 = 0.2x [0.455 ≤ x ≤ 8]x39 = np.linspace(0.455, 8, 100)y39 = 0.2 * x39 - 7.5plt.plot(x39, y39, 'g-', linewidth=1.5) # 40. 直线段: y+8.3 = -0.2x [-12 ≤ x ≤ -1]x40 = np.linspace(-12, -1, 100)y40 = -0.2 * x40 - 8.3plt.plot(x40, y40, 'b-', linewidth=1.5) # 41. 直线段: y+7.35 = -0.13x [-12 ≤ x ≤ 0.455]x41 = np.linspace(-12, 0.455, 100)y41 = -0.13 * x41 - 7.35plt.plot(x41, y41, 'b-', linewidth=1.5) # 42. 直线段: y+8.45 = 0.3x [0.6 ≤ x ≤ 8]x42 = np.linspace(0.6, 8, 100)y42 = 0.3 * x42 - 8.45plt.plot(x42, y42, 'b-', linewidth=1.5) # 43. 直线段: y+7.6 = 0.5x [-2 ≤ x ≤ -1]x43 = np.linspace(-2, -1, 100)y43 = 0.5 * x43 - 7.6plt.plot(x43, y43, 'b-', linewidth=1.5) # 44. 垂直线: x = -2 [-10.5 ≤ y ≤ -8.6]y44 = np.linspace(-10.5, -8.6, 100)x44 = np.full_like(y44, -2)plt.plot(x44, y44, 'b-', linewidth=1.5) # 45. 水平线: y = -10.5 [-2 ≤ x ≤ 0.75]x45 = np.linspace(-2, 0.75, 100)y45 = np.full_like(x45, -10.5)plt.plot(x45, y45, 'b-', linewidth=1.5) # 46. 抛物线: y+7.8 = -(x+0.2)² [0.5 ≤ x ≤ 0.83]x46 = np.linspace(0.5, 0.83, 100)y46 = -(x46 + 0.2) ** 2 - 7.8plt.plot(x46, y46, 'b-', linewidth=1.5) # 47. 垂直线: x = 0.83 [-10.5 ≤ y ≤ -8.861]y47 = np.linspace(-10.5, -8.861, 100)x47 = np.full_like(y47, 0.83)plt.plot(x47, y47, 'b-', linewidth=1.5) # 48. 旋转椭圆弧theta48 = np.linspace(0, np.pi, 500) # 上半部分u48 = 8 * np.cos(theta48)v48 = 8 * np.sin(theta48)x48 = -18 + 0.5 * u48 - 0.866 * v48y48 = -3 + 0.866 * u48 + 0.5 * v48plt.plot(x48, y48, '#FFA500', linewidth=1.5) # 49. 双曲线: 0.423(y+16)-0.906(x+10) = 200/(0.423(x+10)+0.906(y+16))(-24.5<=x<=-14)x49, y49 = np.meshgrid(np.linspace(-24.5, -14, 500), np.linspace(0, 30, 500)) # 主要y的上半部分left = 0.423 * (y49 + 16) - 0.906 * (x49 + 10)right = 200 / (0.423 * (x49 + 10) + 0.906 * (y49 + 16))plt.contour(x49, y49, (left - right), levels=[0], colors='orange', linewidths=1.5) # 50.双曲线:0.866(y-30)-0.5(x+4)=600/(0.866(x+4)+0.5(y-30)){0.866(x+4))+0.5(y-30)}x50, y50 = np.meshgrid(np.linspace(-26, -14, 500), np.linspace(-30, 0, 500))left50 = 0.866 * (y50 - 30) - 0.5 * (x50 + 4)right50 = 600.0 / (0.866 * (x50 + 4) + 0.5 * (y50 - 30))plt.contour(x50, y50, (left50 - right50), levels=[0], colors='orange', linewidths=1.5) # 51. 抛物线: y+5.1 = -0.04(x+25.7)² [-25.7 ≤ x ≤ -14.8]x51 = np.linspace(-25.7, -14.8, 500)y51 = -0.04 * (x51 + 25.7) ** 2 - 5.1plt.plot(x51, y51, '#FFA500', linewidth=1.5) # 52. 双曲线: y = 70/x [-12.15 ≤ x ≤ -6]x52 = np.linspace(-12.15, -6, 500)y52 = 70 / x52plt.plot(x52, y52, 'b-', linewidth=1.5) # 53. 双曲线: y = 50/(x+4) [-12.3 ≤ x ≤ -8.2]x53 = np.linspace(-12.3, -8.2, 500)y53 = 50 / (x53 + 4)plt.plot(x53, y53, 'b-', linewidth=1.5) # 54. 双曲线: y = -70/(x+3.3) [2.5 ≤ x ≤ 8.15]x54 = np.linspace(2.5, 8.15, 500)y54 = -70 / (x54 + 3.3)plt.plot(x54, y54, 'b-', linewidth=1.5) # 55. 双曲线: y = -50/x [4 ≤ x ≤ 8.15]x55 = np.linspace(4, 8.15, 500)y55 = -50 / x55plt.plot(x55, y55, 'b-', linewidth=1.5) # 添加图例和标签# plt.xlabel('X-axis', fontsize=14)# plt.ylabel('Y-axis', fontsize=14)# plt.title('Chicken function', fontsize=16) # 保存并显示图像plt.tight_layout()plt.savefig('complex_functions.png', dpi=250, bbox_inches='tight')plt.show()
图形


阿梓喵
只能说还是高估deepseek了,果然“服务器繁忙了”,最好的一次是上传了两百左右的函数,但是也出现了处理方程时提示信息。
函数
y=-0.17\left(x-0.66\right)^{2}+3.8\left\{-0.542-1.307\left\{\left(y+0.5\right)^{2}\ge0.5\left(x+1.3\right)\right\}\left\{\left(y-0.24\right)^{2}\le12\left(x+1.57\right)\right\}\left\{y\ge-2x-2.56\right\}\left\{\left(y+0.6\right)^{2}\ge6.3\left(x+1\right)\right\}\left\{y\le-0.17\left(x-0.66\right)^{2}+3.8\right\}\left\{y\ge-0.242\right\}x\ge-1.307\left\{y\le-2x-2.56\right\}\left\{\left(y+0.5\right)^{2}\ge0.5\left(x+1.3\right)\right\}\left\{y\ge-0.5\right\}\left(y+0.5\right)^{2}\le0.5\left(x+1.3\right)\left\{\left(y+0.7\right)^{2}\ge3\left(x+0.99\right)\right\}\left\{y\ge-2x-2.56\right\}\left(y+0.56\right)^{2}\le4.8\left(x+1\right)\left\{\left(y+0.5\right)^{2}\ge0.5\left(x+1.3\right)\right\}\left\{\left(y+0.6\right)^{2}\ge4.2\left(x+0.89\right)\right\}\left\{\left(y+0.7\right)^{2}\ge3\left(x+0.99\right)\right\}\left\{y\ge1.3x+1.15\right\}\left(y+0.2\right)^{2}\le4.6\left(x+0.6\right)\left\{\left(y+0.9\right)^{2}\ge5.8\left(x+0.688\right)\right\}\left\{\left(y+0.6\right)^{2}\le4.2\left(x+0.89\right)\right\}\left\{y\ge-0.92\left(x-0.98\right)^{2}+1.94\right\}\left\{y\ge1.3x+1.15\right\}\left(y+0.2\right)^{2}\le4.6\left(x+0.6\right)\left\{\left(y+0.9\right)^{2}\ge5.8\left(x+0.688\right)\right\}\left\{\left(y+0.6\right)^{2}\le4.2\left(x+0.89\right)\right\}\left\{y\ge-0.92\left(x-0.98\right)^{2}+1.94\right\}\left\{y\le1.3x+1.15\right\}\left\{x\le0.3\right\}\left\{y\ge-0.14\right\}y\le1.3x+1.15\left\{y\ge-0.92\left(x-0.98\right)^{2}+1.94\right\}\left\{y\le-3x+4.05\right\}\left\{x\ge0.3\right\}\left\{y\ge-1\right\}y\ge-3x+4.05\left\{y\le1.3x+1.15\right\}\left\{\left(y-0.9\right)^{2}\ge10\left(x-0.7\right)\right\}\left\{1.737\le y\le2.32\right\}\left(y+0.6\right)^{2}\le6.3\left(x+1\right)\left\{\left(y+0.56\right)^{2}\ge4.8\left(x+1\right)\right\}\left\{\left(y-1\right)^{2}\ge3.5\left(x+0.11\right)\right\}\left\{0.4\le y\le2.35\right\}\left(y+0.6\right)^{2}\le6.3\left(x+1\right)\left\{\left(y+0.56\right)^{2}\ge4.8\left(x+1\right)\right\}\left\{\left(y+0.5\right)^{2}\ge0.5\left(x+1.3\right)\right\}\left\{-0.1\le y\le0.4\right\}y\le1.3x+1.15\left\{\left(y+0.5\right)^{2}\ge0.5\left(x+1.3\right)\right\}\left\{\left(y+0.7\right)^{2}\ge3\left(x+0.99\right)\right\}\left\{x\le-0.75\right\}\left\{y\ge-0.1\right\}\left(y+0.6\right)^{2}\le6.3\left(x+1\right)\left\{\left(y-1\right)^{2}\le3.5\left(x+0.11\right)\right\}\left\{\left(y+0.56\right)^{2}\ge4.8\left(x+1\right)\right\}\left\{y\le-0.21\left(x-1\right)^{2}+3.76\right\}y\ge-0.17\left(x-0.66\right)^{2}+3.8\left\{y\le-0.21\left(x-1\right)^{2}+3.76\right\}\left\{\left(y-1\right)^{2}\ge3.5\left(x+0.11\right)\right\}\left(y+0.6\right)^{2}\le6.3\left(x+1\right)\left\{y\le-0.17\left(x-0.66\right)^{2}+3.8\right\}\left\{\left(y-1\right)^{2}\ge3.5\left(x+0.11\right)\right\}\left\{y\ge3.4\right\}\left(y+0.6\right)^{2}\le6.3\left(x+1\right)\left\{\left(y-1\right)^{2}\ge3.5\left(x+0.11\right)\right\}\left\{y\ge2.35\right\}\left\{y\le2.6\right\}y\le1.3x+1.15\left\{\left(y+0.56\right)^{2}\le4.8\left(x+1\right)\right\}\left\{\left(y-0.9\right)^{2}\le10\left(x-0.7\right)\right\}\left\{\left(y-0.42\right)^{2}\ge11\left(x-0.9\right)\right\}\left\{y\ge3.5x-2.9\right\}y\ge-12x+16.8\left\{\left(y+0.56\right)^{2}\le4.8\left(x+1\right)\right\}\left\{\left(y-0.42\right)^{2}\le11\left(x-0.9\right)\right\}\left\{y\ge-6x+8.3\right\}\left\{\left(y-1.4\right)^{2}\le-9\left(x-2.19\right)\right\}\left(y-0.42\right)^{2}\le11\left(x-0.9\right)\left\{y\ge3.5x-2.9\right\}\left\{y\le-12x+16.8\right\}\left(y-0.96\right)^{2}\le5.9\left(x-1.07\right)\left\{y\le3.5x-2.9\right\}\left\{y\le-12x+16.8\right\}y\ge-12x+16.8\left\{y\le-6x+8.3\right\}\left\{\left(y-0.96\right)^{2}\le5.9\left(x-1.07\right)\right\}\left(y+0.56\right)^{2}\le4.8\left(x+1\right)\left\{\left(y-1.4\right)^{2}\ge-9\left(x-2.19\right)\right\}\left\{\left(y-1.87\right)^{2}\le-7\left(x-2.24\right)\right\}\left(y-1.87\right)^{2}\ge-7\left(x-2.24\right)\left\{\left(y+0.56\right)^{2}\le4.8\left(x+1\right)\right\}\left\{y\le-0.21\left(x-1\right)^{2}+3.76\right\}\left\{\left(y-1\right)^{2}\ge-8\left(x-2.45\right)\right\}\left\{\left(y-1.3\right)^{2}\le-16\left(x-2.75\right)\right\}\left\{x\ge2.42\right\}\left(y+0.56\right)^{2}\le4.8\left(x+1\right)\left\{\left(y-1.87\right)^{2}\ge-7\left(x-2.24\right)\right\}\left\{y\le-0.21\left(x-1\right)^{2}+3.76\right\}\left\{\left(y-1\right)^{2}\ge-8\left(x-2.45\right)\right\}\left\{x\le2.42\right\}\left\{y\ge1.48\right\}\left(y-1.87\right)^{2}\ge-7\left(x-2.24\right)\left\{\left(y-1\right)^{2}\le-8\left(x-2.45\right)\right\}\left\{y\ge-31\left(x-2.22\right)^{2}+1.5\right\}\left\{x\ge2.22\right\}\left(y-1.3\right)^{2}\ge-16\left(x-2.75\right)\left\{y\le-0.66\left(x-2.12\right)^{2}+3.37\right\}\left\{\left(y+0.1\right)^{2}\ge-12\left(x-2.93\right)\right\}\left\{\left(y-0.8\right)^{2}\le-8.4\left(x-3.47\right)\right\}\left(y-0.8\right)^{2}\ge-8.4\left(x-3.47\right)\left\{y\le-0.66\left(x-2.12\right)^{2}+3.37\right\}\left\{\left(y-1\right)^{2}\le-4.6\left(x-3.77\right)\right\}\left(y-1\right)^{2}\ge-4.6\left(x-3.77\right)\left\{\left(y-0.4\right)^{2}\le-7.4\left(x-3.85\right)\right\}\left\{\left(y+0.7\right)^{2}\ge-22\left(x-3.16\right)\right\}\left\{\left(y-0.8\right)^{2}\ge-8.4\left(x-3.47\right)\right\}\left(y-0.4\right)^{2}\ge-7.4\left(x-3.85\right)\left\{\left(y+0.7\right)^{2}\ge-22\left(x-3.16\right)\right\}\left\{\left(y+3.66\right)^{2}\ge-1.1\left(x-3\right)\right\}\left\{y\ge9x-32.7\right\}\left\{\left(y+2.3\right)^{2}\le-7.6\left(x-3.4\right)\right\}\left\{y\ge-7x+16.3\right\}\left(y+3.66\right)^{2}\le-1.1\left(x-3\right)\left\{\left(y+0.7\right)^{2}\ge-22\left(x-3.16\right)\right\}\left(y+2.3\right)^{2}\le-7.6\left(x-3.4\right)\left\{y\le9x-32.7\right\}\left(y-0.4\right)^{2}\ge-7.4\left(x-3.85\right)\left\{\left(y+2.3\right)^{2}\ge-7.6\left(x-3.4\right)\right\}\left\{y^{2}\ge20.5\left(x-3.44\right)\right\}\left\{\left(y+2\right)^{2}\le10\left(x-3.37\right)\right\}\left\{y\ge-4.25\right\}\left(y+2.3\right)^{2}\ge-7.6\left(x-3.4\right)\left\{\left(y-0.4\right)^{2}\ge-7.4\left(x-3.85\right)\right\}\left\{\left(y+2\right)^{2}\ge10\left(x-3.37\right)\right\}\left\{y\ge-1.9\right\}\left\{y\le-1.4\right\}\left(y+2.3\right)^{2}\ge-7.6\left(x-3.4\right)\left\{y\ge-3.5x+8.52\right\}\left\{\left(y+2\right)^{2}\ge10\left(x-3.37\right)\right\}\left\{-4.25\le y\le-2.5\right\}\left(y-1.3\right)^{2}\ge-16\left(x-2.75\right)\left\{\left(y+0.1\right)^{2}\le-12\left(x-2.93\right)\right\}\left\{y\ge-9x+23.2\right\}y\le-9x+23.2\left\{y\le1.6x-5.35\right\}\left\{\left(y+0.1\right)^{2}\le-12\left(x-2.93\right)\right\}\left\{\left(y+2.5\right)^{2}\ge-6\left(x-2.38\right)\right\}\left\{\left(y+2\right)^{2}\ge-14\left(x-2.32\right)\right\}\left(y+2\right)^{2}\ge-14\left(x-2.32\right)\left\{\left(y+2.5\right)^{2}\le-6\left(x-2.38\right)\right\}\left(y+0.1\right)^{2}\ge-12\left(x-2.93\right)\left\{\left(y-0.8\right)^{2}\ge-8.4\left(x-3.47\right)\right\}\left\{\left(y+0.7\right)^{2}\le-22\left(x-3.16\right)\right\}\left\{y\ge-5x+9.3\right\}\left\{y\le-0.81\right\}y\le-5x+9.3\left\{y\le10x-29.5\right\}\left\{\left(y+0.7\right)^{2}\le-22\left(x-3.16\right)\right\}\left\{\left(y+3.66\right)^{2}\le-1.1\left(x-3\right)\right\}y\le-0.92\left(x-0.98\right)^{2}+1.94\left\{y\le-3x+4.05\right\}\left\{\left(y-0.9\right)^{2}\ge10\left(x-0.7\right)\right\}\left\{y\ge-\left(x+0.6\right)^{2}-0.56\right\}\left\{\left(y+2.3\right)^{2}\ge-0.7\left(x-1.9\right)\right\}\left\{y\ge x-2.706\right\}y\ge-0.92\left(x-0.98\right)^{2}+1.94\left\{\left(y+0.9\right)^{2}\le5.8\left(x+0.688\right)\right\}\left\{y\le1.3\right\}\left\{x\le0.144\right\}\left(y+0.9\right)^{2}\ge5.8\left(x+0.688\right)\left\{\left(y+0.2\right)^{2}\ge4.6\left(x+0.6\right)\right\}\left\{\left(y+0.6\right)^{2}\le4.2\left(x+0.89\right)\right\}\left\{y\ge-\left(x+0.6\right)^{2}-0.56\right\}\left(y+0.6\right)^{2}\ge4.2\left(x+0.89\right)\left\{\left(y+0.7\right)^{2}\le3\left(x+0.99\right)\right\}\left\{y\ge-\left(x+0.6\right)^{2}-0.56\right\}y\le-\left(x+0.6\right)^{2}-0.56\left\{y\ge-0.9\left(x+0.65\right)^{2}-0.77\right\}\left\{y\ge2x+0.98\right\}\left\{x\ge-1\right\}y\ge-0.9\left(x+0.65\right)^{2}-0.77\left\{y\le-\left(x+0.6\right)^{2}-0.56\right\}\left\{y\ge0.24\left(x-0.5\right)^{2}-3.076\right\}\left\{x\ge0.04\right\}y\ge-\left(x+0.6\right)^{2}-0.56\left\{\left(y+2.3\right)^{2}\le-0.7\left(x-1.9\right)\right\}\left\{y\ge0.24\left(x-0.5\right)^{2}-3.076\right\}\left\{x\ge0.2\right\}y\le-0.9\left(x+0.65\right)^{2}-0.77\left\{y\ge-0.95x-3.2\right\}\left\{y\ge-0.7x-3.14\right\}\left\{y\ge0.2x-3.22\right\}\left\{x\ge-1\right\}\left\{\left(y+2.43\right)^{2}\ge0.34\left(x+0.11\right)\right\}\left\{y\le-x-2.626\right\}y\le-0.9\left(x+0.65\right)^{2}-0.77\left\{y\ge-0.95x-3.2\right\}\left\{y\ge-0.7x-3.14\right\}\left\{y\ge0.2x-3.22\right\}\left\{x\ge-1\right\}\left\{\left(y+2.43\right)^{2}\ge0.34\left(x+0.11\right)\right\}\left\{x\le-0.04\right\}\left\{y\ge-x-2.626\right\}y\le-0.9\left(x+0.65\right)^{2}-0.77\left\{y\ge-1.2\left(x-0.13\right)^{2}-2.22\right\}\left\{x\ge-0.04\right\}y\le-1.2\left(x-0.13\right)^{2}-2.22\left\{\left(y+2.51\right)^{2}\ge-0.3\left(x-0.55\right)\right\}\left\{y\ge-x-2.626\right\}\left\{y\ge0.2x-3.22\right\}\left(y+2.51\right)^{2}\le-0.3\left(x-0.55\right)\left\{y\ge-x-2.626\right\}\left\{y\le-2.76\right\}\left(y-0.9\right)^{2}\le10\left(x-0.7\right)\left\{y\le3.5x-2.9\right\}\left\{\left(y-0.96\right)^{2}\ge5.9\left(x-1.07\right)\right\}\left\{y\le-6x+8.3\right\}\left\{y\ge0.15x-1.48\right\}y\le0.15x-1.48\left\{y\le-10x+11.9\right\}\left\{y\ge x-2.706\right\}\left\{\left(y-0.9\right)^{2}\le10\left(x-0.7\right)\right\}y\le x-2.706\left\{y\le0.15x-1.655\right\}\left\{\left(y+2.3\right)^{2}\ge-0.7\left(x-1.9\right)\right\}\left\{\left(y+2.79\right)^{2}\ge2.55\left(x-1.81\right)\right\}\left\{y\ge1.6x-5.35\right\}\left\{y\le-2\left(x-1.69\right)^{2}-1.4\right\}\left\{y\ge-2.3\right\}y\ge-2\left(x-1.69\right)^{2}-1.4\left\{y\le0.15x-1.655\right\}\left\{y\le x-2.706\right\}\left\{\left(y+2.3\right)^{2}\ge-0.7\left(x-1.9\right)\right\}\left\{1.1
代码
import numpy as npimport matplotlib.pyplot as pltimport math plt.rcParams['font.sans-serif'] = ['SimHei'] # 使用黑体显示中文plt.rcParams['axes.unicode_minus'] = False # 正常显示负号 # 设置图形大小plt.figure(figsize=(15, 12)) # 存储所有线段的点all_points_x = []all_points_y = [] # 定义绘图函数def plot_segment(equation_type, expr, interval_str): try: # 解析区间字符串 interval_str = interval_str.strip('{}') parts = interval_str.split('') if len(parts) == 3: upper = float(parts[0]) var_char = parts[1].strip() lower = float(parts[2]) else: # 尝试其他格式 if 'x' in interval_str: parts = interval_str.split('x') if len(parts) == 2: if parts[0].endswith('') and parts[1].startswith('>'): lower = float(parts[1].replace('>', '').strip()) upper = float(parts[0].replace('>', '').strip()) var_char = 'x' elif 'y' in interval_str: parts = interval_str.split('y') if len(parts) == 2: if parts[0].endswith('') and parts[1].startswith('>'): lower = float(parts[1].replace('>', '').strip()) upper = float(parts[0].replace('>', '').strip()) var_char = 'y' # 根据类型生成点 if equation_type == 'explicit_y': # y = f(x) if var_char == 'x': x_vals = np.linspace(lower, upper, 100) # 在 eval 中加入 x 的定义 y_vals = [eval(expr, {'x': x, 'math': math, 'np': np}) for x in x_vals] all_points_x.extend(x_vals) all_points_y.extend(y_vals) elif var_char == 'y': y_vals = np.linspace(lower, upper, 100) x_vals = [eval(expr, {'y': y, 'math': math, 'np': np}) for y in y_vals] all_points_x.extend(x_vals) all_points_y.extend(y_vals) elif equation_type == 'explicit_x': # x = constant if var_char == 'y': y_vals = np.linspace(lower, upper, 100) x_vals = [eval(expr) for _ in y_vals] all_points_x.extend(x_vals) all_points_y.extend(y_vals) elif var_char == 'x': x_val = eval(expr) y_vals = np.linspace(lower, upper, 100) x_vals = [x_val for _ in y_vals] all_points_x.extend(x_vals) all_points_y.extend(y_vals) elif equation_type == 'implicit_y': # x = f(y) y_vals = np.linspace(lower, upper, 100) x_vals = [eval(expr, {'y': y, 'math': math, 'np': np}) for y in y_vals] all_points_x.extend(x_vals) all_points_y.extend(y_vals) except Exception as e: print(f"处理方程时出错: {equation_type}, {expr}, {interval_str}") print(f"错误: {e}") # 定义所有方程及其参数equations = [ # 原始方程(保持不变) {'type': 'explicit_y', 'expr': '-0.17*(x-0.66)**2 + 3.8', 'interval': '{-0.542= -4*(x+2.46)**2 - 0.8}' }, { 'type': 'explicit_y', 'expr': '-9*(x+2.03)**2 + 1.64', 'interval': '{(y-1.45)**2 = -(x+1.93) and x >= -2.44 and y = 13*(x+2.39) and y >= -4*(x+2.46)**2 - 0.8 and -2.44= -(x+1.93) and (y+0.1)**2 >= 12*(x+2.07) and y = -(x+1.93) and y >= 1.5*x + 4.287}' }, { 'type': 'explicit_y', 'expr': '3.6*x + 8.32', 'interval': '{(y-1.45)**2 >= -(x+1.93) and y = 1.288}' }, { 'type': 'explicit_y', 'expr': '-3*(x+2.2)**2 + 1.91', 'interval': '{(y-1.6)**2 = -3*(x+2.2)**2 + 1.91 and (y-0.24)**2 >= 12*(x+1.57)}' }, { 'type': 'explicit_y', 'expr': '-3*(x+2.2)**2 + 1.91', 'interval': '{(y+0.1)**2 = 12*(x+1.57) and y >= -6*x - 9.7 and y >= -0.52}' }, { 'type': 'explicit_y', 'expr': '-6*x - 9.7', 'interval': '{(y+0.1)**2 = -0.85*x - 2.844}' }, { 'type': 'explicit_y', 'expr': '-0.85*x - 2.844', 'interval': '{(y+0.1)**2 >= 12*(x+2.07) and x >= -2.08 and y = -1.17}' }, { 'type': 'explicit_y', 'expr': '-6*(x+1.81)**2 - 1.74', 'interval': '{(y+1.43)**2 >= -0.6*(x+1.8) and (y+1.5)**2 >= -(x+1.83) and y >= -6*(x+1.81)**2 - 1.74 and y = -1.1*x - 4.95 and x >= -1.89}' }, { 'type': 'explicit_y', 'expr': '-6*(x+1.81)**2 - 1.74', 'interval': '{y = -1.1*x - 4.95}' }, { 'type': 'explicit_y', 'expr': '-6*x - 8.65', 'interval': '{(y-0.24)**2 = 12*(x+1.57) and y >= -6*x - 9.7 and y >= 8*x + 5.9 and y = 0.5*(x+1.3) and -1.307= 8*x + 5.9 and (y-0.24)**2 -1.307 and (y+0.5)**2 >= 0.5*(x+1.3) and (y-0.24)**2 = -2*x - 2.56 and (y+0.6)**2 >= 6.3*(x+1) and y = -0.242}' }, { 'type': 'explicit_y', 'expr': '-2*x - 2.56', 'interval': '{x >= -1.307 and y = 0.5*(x+1.3) and y >= -0.5}' }, { 'type': 'explicit_y', 'expr': '-0.17*(x-0.66)**2 + 3.8', 'interval': '{(y+0.5)**2 = 3*(x+0.99)}' }, { 'type': 'explicit_y', 'expr': '-0.17*(x-0.66)**2 + 3.8', 'interval': '{(y+0.6)**2 = 3.5*(x+0.11) and y >= -0.17*(x-0.66)**2 + 3.8 and y >= 3.4}' }, { 'type': 'implicit_y', 'expr': '-7.6*(x - 3.4)', 'interval': '{(y + 2.3)**2 >= -7.6*(x - 3.4) and (y - 0.4)**2 >= -7.4*(x - 3.85) and (y + 2)**2 >= 10*(x - 3.37) and y >= -1.9 and y = -7.6*(x - 3.4) and y >= -3.5*x + 8.52 and (y + 2)**2 >= 10*(x - 3.37) and -4.25 = -16*(x - 2.75) and (y + 0.1)**2 = -9*x + 23.2}' }, { 'type': 'explicit_y', 'expr': '-9*x + 23.2', 'interval': '{y = -6*(x - 2.38) and (y + 2)**2 >= -14*(x - 2.32)}' }, { 'type': 'implicit_y', 'expr': '-6*(x - 2.38)', 'interval': '{(y + 2)**2 >= -14*(x - 2.32) and (y + 2.5)**2 = -12*(x - 2.93) and (y - 0.8)**2 >= -8.4*(x - 3.47) and (y + 0.7)**2 = -5*x + 9.3 and y = 10*(x - 0.7) and y >= -(x + 0.6)**2 - 0.56 and (y + 2.3)**2 >= -0.7*(x - 1.9) and y >= x - 2.706}' }, { 'type': 'implicit_y', 'expr': '5.8*(x + 0.688)', 'interval': '{(y + 0.9)**2 >= 5.8*(x + 0.688) and y = 5.8*(x + 0.688) and (y + 0.2)**2 >= 4.6*(x + 0.6) and (y + 0.6)**2 = -(x + 0.6)**2 - 0.56}' }, { 'type': 'implicit_y', 'expr': '4.2*(x + 0.89)', 'interval': '{(y + 0.6)**2 >= 4.2*(x + 0.89) and (y + 0.7)**2 = -(x + 0.6)**2 - 0.56}' }, { 'type': 'implicit_y', 'expr': '-0.7*(x - 1.9)', 'interval': '{y = -0.9*(x + 0.65)**2 - 0.77 and y >= 2*x + 0.98 and x >= -1}' }, { 'type': 'implicit_y', 'expr': '-12*(x - 2.93)', 'interval': '{y = -0.9*(x + 0.65)**2 - 0.77 and y >= 0.24*(x - 0.5)**2 - 3.076 and x >= 0.04}' }, { 'type': 'implicit_y', 'expr': '-0.7*(x - 1.9)', 'interval': '{(y + 2.3)**2 = 0.24*(x - 0.5)**2 - 3.076 and x >= 0.2}' }, { 'type': 'explicit_y', 'expr': '-0.9*(x + 0.65)**2 - 0.77', 'interval': '{y >= -0.95*x - 3.2 and y >= -0.7*x - 3.14 and y >= 0.2*x - 3.22 and x >= -1 and (y + 2.43)**2 >= 0.34*(x + 0.11) and y = -0.95*x - 3.2 and y >= -0.7*x - 3.14 and y >= 0.2*x - 3.22 and x >= -1 and (y + 2.43)**2 >= 0.34*(x + 0.11) and x = -x - 2.626}' }, { 'type': 'explicit_y', 'expr': '-1.2*(x - 0.13)**2 - 2.22', 'interval': '{y >= -0.9*(x + 0.65)**2 - 0.77 and x >= -0.04}' }, { 'type': 'explicit_y', 'expr': '-1.2*(x - 0.13)**2 - 2.22', 'interval': '{(y + 2.51)**2 >= -0.3*(x - 0.55) and y >= -x - 2.626 and y >= 0.2*x - 3.22}' }, { 'type': 'implicit_y', 'expr': '-0.3*(x - 0.55)', 'interval': '{(y + 2.51)**2 = -x - 2.626 and y = 5.9*(x - 1.07) and y = 0.15*x - 1.48}' }, { 'type': 'explicit_y', 'expr': '0.15*x - 1.48', 'interval': '{y = x - 2.706 and (y - 0.9)**2 = -0.7*(x - 1.9) and y >= 1.6*x - 5.35 and y = -2.3}' }, { 'type': 'implicit_y', 'expr': '-14*(x - 2.32)', 'interval': '{(y + 2)**2 >= -14*(x - 2.32) and y = -0.7*(x - 1.9) and 1.1 = -9*(x - 2.19) and y = -7*(x - 2.24) and (y + 2.79)**2 >= 2.55*(x - 1.81) and y >= 1.6*x - 5.35 and y >= -2.2*(x - 1.73)**2 - 1.22 and x = -9*(x - 2.19) and y >= -31*(x - 2.22)**2 + 1.5 and y >= -6*x + 8.3 and y >= 0.15*x - 1.48 and x = -2.2*(x - 1.73)**2 - 1.22 and y >= -31*(x - 2.22)**2 + 1.5 and 1.72 = -16*(x - 2.75) and y >= 1.6*x - 5.35 and y = 2.42}' }, { 'type': 'implicit_y', 'expr': '-0.7*(x - 1.9)', 'interval': '{(y - 1.3)**2 >= -16*(x - 2.75) and y >= -10*x + 18.6 and y >= -2*(x - 1.69)**2 - 1.4 and (y + 2.79)**2 >= 2.55*(x - 1.81)}' }, { 'type': 'implicit_y', 'expr': '2.55*(x - 1.81)', 'interval': '{(y + 2.79)**2 = 2.1*(x - 1.82)**2 - 2.35 and (y + 2)**2 = -12*(x - 2.93) and y >= 50*x + 103.3}' }, { 'type': 'explicit_y', 'expr': '-0.85*x - 2.844', 'interval': '{y = 1.2*(x + 3.15)**2 - 2.8}' }, { 'type': 'implicit_y', 'expr': '-0.6*(x + 1.8)', 'interval': '{(y + 1.43)**2 >= -0.6*(x + 1.8) and y = -2.37}' }, { 'type': 'implicit_y', 'expr': '-0.88*(x + 1.64)', 'interval': '{(y + 1.8)**2 = -2.524}' }, { 'type': 'implicit_y', 'expr': '-0.6*(x + 1.8)', 'interval': '{(y + 1.43)**2 >= -0.6*(x + 1.8) and (y + 1.5)**2 = -4*(x + 2.46)**2 - 0.8}' }, { 'type': 'implicit_y', 'expr': '3.2*(x + 1.88)', 'interval': '{(y + 2.3)**2 >= 3.2*(x + 1.88) and y = 1.2*(x + 3.15)**2 - 2.8}' }, { 'type': 'implicit_y', 'expr': '2.55*(x - 1.81)', 'interval': '{(y + 2.79)**2 = -1.5*(x + 2.9)**2 - 1.1 and y = -9*(x + 3.38)**2 - 1.5 and x >= -3.4}' }, { 'type': 'explicit_y', 'expr': '-9*(x + 3.38)**2 - 1.5', 'interval': '{y >= -1.9*(x + 2.68)**2 - 0.92 and x >= -3.655}' }, { 'type': 'implicit_y', 'expr': '1.5*(x + 0.65)', 'interval': '{(y + 4.6)**2 = 2*(x + 0.96) and y >= -x - 3.77 and (y + 2.45)**2 = -0.42 and y = -12*(x - 0.9) and (y + 2)**2 = -4.25}' }, { 'type': 'explicit_y', 'expr': '0.24*(x - 0.5)**2 - 3.076', 'interval': '{(y + 2.5)**2 >= -12*(x - 0.9) and y = -0.25*(x - 2.5)**2 - 2.72 and y >= -3.5}' }, { 'type': 'implicit_y', 'expr': '-6*(x - 2.38)', 'interval': '{(y + 2.5)**2 >= -6*(x - 2.38) and y = -14*(x - 2.32) and y >= 10*x - 29.5 and y >= -4.25}' }, { 'type': 'implicit_y', 'expr': '-7.6*(x - 3.4)', 'interval': '{(y + 2.3)**2 >= -7.6*(x - 3.4) and (y - 0.4)**2 >= -7.4*(x - 3.85) and (y + 2)**2 >= 10*(x - 3.37) and y >= -4.25 and y = -4.25}' }, { 'type': 'implicit_y', 'expr': '3.2*(x + 1.88)', 'interval': '{(y + 2.3)**2 >= 3.2*(x + 1.88) and x >= -2.4 and y >= -4.25 and y = 3.2*(x + 1.88) and y = -3}' }, { 'type': 'implicit_y', 'expr': '-0.7*(x + 2.3)', 'interval': '{(y + 2.45)**2 >= -0.7*(x + 2.3) and (y + 3.7)**2 = -2.55*(x + 3.4) and (y + 3.8)**2 >= (x + 4.43) and (y + 3.11)**2 >= 0.3*(x + 3.84) and -4.15 = -1.1*(x - 3) and y <= -7*x + 16.3 and -4.25 <= y <= -4}' },] # 处理所有方程for eq in equations: plot_segment(eq['type'], eq['expr'], eq['interval']) # 绘制所有点plt.scatter(all_points_x, all_points_y, s=1, color='black') # 设置坐标轴范围和标签plt.xlim(-5, 5)plt.ylim(-5, 5)plt.xlabel('x')plt.ylabel('y')plt.title('阿梓喵')plt.grid(True, linestyle='--', alpha=0.7)plt.axhline(0, color='gray', linewidth=0.5)plt.axvline(0, color='gray', linewidth=0.5) # 显示图形plt.tight_layout()plt.show()
图形


芙莉莲&勇者
函数太多了,网站没敢爬,还是采用最原始的全选复制粘贴,太消耗时间了。
函数
y=-0.35\left(x+3.1\right)^{2}+4.4\left\{-3.64-3.92\right\}y\le0.2x+0.725\left\{x\ge-3.94\right\}\left\{y\ge0.2x+0.45\right\}\left\{y\le-7x-26.3\right\}y\le-1.8\left(x+3.82\right)^{2}+0.03\left\{y\ge1.4x+4.89\right\}\left\{y\ge-7x-26.3\right\}y\le-7x-26.3\left\{y\ge0.2x+0.725\right\}\left\{y\le-1.8\left(x+3.82\right)^{2}+0.03\right\}y\ge-1.8\left(x+3.82\right)^{2}+0.03\left\{y\le0.4x+1.58\right\}\left\{y\ge-7\left(x+4.66\right)^{2}-1.33\right\}\left\{\left(y+1.4\right)^{2}\le12\left(x+4.93\right)\right\}\left\{x\le-3.95\right\}y\le-1.8\left(x+3.82\right)^{2}+0.03\left\{y\ge-7\left(x+4.66\right)^{2}-1.33\right\}\left\{y+1.56\ge-0.5\left(x+4.3\right)^{2}\right\}\left\{x\le-3.94\right\}\left\{y\le0.2x+0.725\right\}y\le-7\left(x+4.66\right)^{2}-1.33\left\{y+1.56\ge-0.5\left(x+4.3\right)^{2}\right\}\left\{\left(y+1.7\right)^{2}\ge12\left(x+4.77\right)\right\}\left(y+1.5\right)^{2}\le11\left(x+4.56\right)\left\{y\le-7\left(x+4.66\right)^{2}-1.33\right\}\left\{y+1.56\ge-0.5\left(x+4.3\right)^{2}\right\}x\ge-3.94\left\{y\le0.2x+0.45\right\}\left\{y+1.56\ge-0.5\left(x+4.3\right)^{2}\right\}\left\{y\le0.26\left(x+3.13\right)^{2}-0.4\right\}\left\{y\le-2x-5.98\right\}\left\{y\ge0.43x-2.124\right\}y+1.56\le-0.5\left(x+4.3\right)^{2}\left\{\left(y+2\right)^{2}\ge-12\left(x+3.8\right)\right\}\left\{y\ge-0.7\left(x+4\right)^{2}-2.77\right\}\left\{y\ge0.32\left(x+3\right)^{2}-3.27\right\}y+2.69\le2\left(x+4\right)^{2}\left\{y\ge-1.5x-8.83\right\}\left\{y\ge-0.7\left(x+4\right)^{2}-2.77\right\}\left\{\left(y+2\right)^{2}\le-12\left(x+3.8\right)\right\}\left\{y\le-2.69\right\}y\ge-2.69\left\{y+2.69\le2\left(x+4\right)^{2}\right\}\left\{\left(y+2\right)^{2}\le-12\left(x+3.8\right)\right\}\left\{x\ge-4\right\}\left(y+3.5\right)^{2}\ge-13\left(x+3.43\right)\left\{y\le-0.7\left(x+4\right)^{2}-2.77\right\}\left\{y\ge0.32\left(x+3\right)^{2}-3.27\right\}y\ge-2x-5.98\left\{y\le-0.2x-0.98\right\}\left\{y\le-2.17\left(x+2.77\right)^{2}-0.4\right\}y\ge-2x-5.98\left\{y\ge-\left(x+1.4\right)^{2}-2.77\right\}\left\{y\ge0.6x-2.04\right\}\left\{\left(y+1.3\right)^{2}\ge1.5\left(x+2.1\right)\right\}\left\{\left(y+3.4\right)^{2}\le-1.8\left(x+0.75\right)\right\}\left\{y\ge-2.17\left(x+2.77\right)^{2}-0.4\right\}y\ge-2.17\left(x+2.77\right)^{2}-0.4\left\{\left(y+3.4\right)^{2}\ge-1.8\left(x+0.75\right)\right\}\left\{\left(y+1.3\right)^{2}\ge1.5\left(x+2.1\right)\right\}\left\{-2.1580.001\right\}y+1.56\le-0.5\left(x+4.3\right)^{2}\left\{y\ge-\left(x+4.2\right)^{2}-1.74\right\}\left\{y\ge-0.37\left(x+4.2\right)^{2}-1.74\right\}\left\{\left(y+2\right)^{2}\le-12\left(x+3.8\right)\right\}\left\{y\ge-6x-32.1\right\}\left\{\left(y+1.7\right)^{2}\ge12\left(x+4.77\right)\right\}y+1.56\le-0.5\left(x+4.3\right)^{2}\left\{y\ge-\left(x+4.2\right)^{2}-1.74\right\}\left\{y\ge-0.37\left(x+4.2\right)^{2}-1.74\right\}\left\{\left(y+2\right)^{2}\le-12\left(x+3.8\right)\right\}\left\{y\ge-6x-32.1\right\}\left\{\left(y+1.5\right)^{2}\le11\left(x+4.56\right)\right\}y\le-0.37\left(x+4.2\right)^{2}-1.74\left\{y\ge-\left(x+4.2\right)^{2}-1.74\right\}\left\{\left(y+2\right)^{2}\le-12\left(x+3.8\right)\right\}\left\{x>-4.2\right\}y\le-0.46\left(x+4.24\right)^{2}-1.87\left\{y\ge-6x-32.1\right\}\left\{y+2.85\ge2.5\left(x+4.7\right)^{2}\right\}\left\{\left(y+1.7\right)^{2}\ge12\left(x+4.77\right)\right\}\left(y+1.5\right)^{2}\le11\left(x+4.56\right)\left\{y\le-0.46\left(x+4.24\right)^{2}-1.87\right\}\left\{y\le-0.7\left(x+4.24\right)^{2}-1.87\right\}\left\{y\ge-2.61\right\}\left\{\left(y+2\right)^{2}\le-12\left(x+3.8\right)\right\}y\ge-0.7\left(x+4.24\right)^{2}-1.87\left\{\left(y+1.5\right)^{2}\le11\left(x+4.56\right)\right\}\left\{y\le-0.46\left(x+4.24\right)^{2}-1.87\right\}\left\{x\le-4.24\right\}y\le-2.61\left\{\left(y+1.5\right)^{2}\le11\left(x+4.56\right)\right\}\left\{y\ge-0.76\left(x+4.15\right)^{2}-2.61\right\}\left\{x\le-4.15\right\}y\le-0.76\left(x+4.15\right)^{2}-2.61\left\{y+2.85\ge2.5\left(x+4.7\right)^{2}\right\}\left\{y\ge30\left(x+4.5\right)\right\}\left\{\left(y+1.7\right)^{2}\le12\left(x+4.77\right)\right\}y\ge-1.5x-8.83\left\{y\le-2.61\right\}\left\{y\ge-2.69\right\}\left\{y+2.69\ge2\left(x+4\right)^{2}\right\}\left\{\left(y+2\right)^{2}\le-12\left(x+3.8\right)\right\}y+2.69\le2\left(x+4\right)^{2}\left\{y\ge-1.5x-8.83\right\}\left\{y\ge-2.69\right\}\left\{x\le-4\right\}\left\{y\le-2.66\right\}y+2.85\le2.5\left(x+4.7\right)^{2}\left\{x\ge-4.69\right\}\left\{y\ge-4\left(x+5.486\right)\right\}\left\{\left(y+3.23\right)^{2}\le0.17\left(x+4.68\right)\right\}\left\{\left(y+2.8\right)^{2}\ge1.1\left(x+4.68\right)\right\}\left(y+3.23\right)^{2}\ge0.17\left(x+4.68\right)\left\{y\ge-4\left(x+5.486\right)\right\}\left\{x\ge-4.69\right\}\left\{y+2.85\le2.5\left(x+4.7\right)^{2}\right\}\left\{y\ge30\left(x+4.5\right)\right\}\left\{y\ge-3.228\right\}\left(y+2.8\right)^{2}\le1.1\left(x+4.68\right)\left\{\left(y+3.23\right)^{2}\le0.17\left(x+4.68\right)\right\}\left\{y\le-20\left(x+4.18\right)\right\}\left\{y\le-3.36\right\}y\le-0.76\left(x+4.15\right)^{2}-2.61\left\{y\le30\left(x+4.5\right)\right\}\left\{\left(y+2.8\right)^{2}\le1.1\left(x+4.68\right)\right\}\left\{y\ge14\left(x+4.404\right)^{2}-3.335\right\}y\le30\left(x+4.5\right)\left\{\left(y+2.8\right)^{2}\le1.1\left(x+4.68\right)\right\}\left\{y\le14\left(x+4.404\right)^{2}-3.335\right\}\left\{x-0.344\right\}y\le-1.298\left\{y\ge-0.7x-1.265\right\}\left\{\left(y+1.28\right)^{2}\ge0.5\left(x-0.11\right)\right\}\left\{x\le0.12\right\}y\le-0.8x-1.642\left\{y\ge-x-1.655\right\}\left\{y\le16\left(x-0.13\right)^{2}-1.77\right\}\left\{x\le0.093\right\}y\le16\left(x-0.13\right)^{2}-1.77\left\{y\ge16\left(x-0.21\right)^{2}-1.76\right\}\left\{y\le-4\left(x+0.1\right)^{2}-1.3\right\}y\le-0.9x-2.07\left\{y\ge4\left(x+0.5\right)^{2}-1.625\right\}\left\{y\ge-2.5x-3.2\right\}y\le-7\left(x+0.44\right)^{2}-1.582\left\{x\le-0.3\right\}\left\{y\ge9\left(x+0.35\right)^{2}-1.785\right\}y\ge-6.5\left(x+0.56\right)^{2}-1.622\left\{y\le-7\left(x+0.44\right)^{2}-1.582\right\}\left\{y\le9\left(x+0.35\right)^{2}-1.785\right\}\left\{y\ge-1.715\right\}y\le-15\left(x+0.6\right)^{2}-1.61\left\{y\ge-5x-4.74\right\}\left\{y\ge-1.5x-2.78\right\}\left\{y\ge-0.6x-2.38\right\}y\ge-15\left(x+0.6\right)^{2}-1.61\left\{y\le-6.5\left(x+0.56\right)^{2}-1.622\right\}\left\{y\ge-0.6x-2.38\right\}\left\{y\le17\left(x+0.33\right)^{2}-1.925\right\}\left\{x\ge-0.571\right\}y\ge-6.5\left(x+0.56\right)^{2}-1.622\left\{y\le\left(x-0.1\right)^{2}-2.12\right\}\left\{y\ge-0.6x-2.38\right\}\left\{y\ge-0.2x-2.35\right\}\left\{y\le-1.3x-1.23\right\}\left\{y\ge2x-4\right\}\left\{x\ge-0.345\right\}y\le-0.2x-2.35\left\{y\ge-\left(x-0.2\right)^{2}-2.4\right\}\left\{y\ge2x-4\right\}\left\{x\ge0.262\right\}y\ge-1.3x-1.23\left\{y\le-0.8x-1.59\right\}\left\{y\ge2x-4\right\}y\ge\left(x-0.1\right)^{2}-2.12\left\{\left(y+2.2\right)^{2}\ge-0.4\left(x-0.173\right)\right\}\left\{y\le-0.4x-1.72\right\}\left\{y\le1.4\left(x-0.03\right)^{2}-1.82\right\}\left\{y\ge-11\left(x+0.238\right)^{2}-1.73\right\}\left\{y\le-1.82\right\}y\le-11\left(x+0.238\right)^{2}-1.73\left\{y\ge2.3\left(x+0.06\right)^{2}-1.95\right\}\left\{x\ge-0.283\right\}y\ge-11\left(x+0.238\right)^{2}-1.73\left\{y\le1.4\left(x-0.03\right)^{2}-1.82\right\}\left\{y\ge-1.82\right\}\left\{-0.2072.05\right\}y\le15x-32.7\left\{y\ge3.1\left(x-2.5\right)^{2}-0.26\right\}\left\{y\ge30x-74.6\right\}\left\{\left(y-0.1\right)^{2}\le1.1\left(x-1.64\right)\right\}y^{2}\le-\left(x-2.497\right)\left\{y\le30x-74.6\right\}y\le30x-74.6\left\{y\ge-x+2.59\right\}\left\{y\le-8x+20.47\right\}y\ge-8x+20.47\left\{y\ge-4\left(x-2.48\right)^{2}+0.29\right\}\left\{y\le30x-74.6\right\}\left\{\left(y-0.1\right)^{2}\le1.1\left(x-1.64\right)\right\}\left\{y\le-1.4\left(x-2.7\right)^{2}+1.28\right\}\left\{x\le3.343\right\}\left\{y\ge-x+3.16\right\}y\ge-1.4\left(x-2.7\right)^{2}+1.28\left\{y\le1.9\left(x-3.54\right)^{2}+0.71\right\}\left\{y\ge0.3\left(x-3.52\right)^{2}+0.71\right\}\left\{3.208
代码
import numpy as npimport matplotlib.pyplot as pltfrom matplotlib.patches import Ellipse # 设置图形大小plt.figure(figsize=(12, 10)) # 1. y = -0.35*(x+3.1)**2 + 4.4 for -3.64 < x < -3.1x1 = np.linspace(-3.64, -3.1, 100)y1 = -0.35 * (x1 + 3.1)**2 + 4.4plt.plot(x1, y1, 'k') # 2. y = -0.84*(x+3.1)**2 + 4.4 for -3.1 < x < -2.35x2 = np.linspace(-3.1, -2.35, 100)y2 = -0.84 * (x2 + 3.1)**2 + 4.4plt.plot(x2, y2, 'k') # 3. (y-3.66)**2 = -0.76*(x+2.257) for 3.46 < y < 3.92y3 = np.linspace(3.46, 3.92, 100)x3 = -2.257 - (y3 - 3.66)**2 / 0.76plt.plot(x3, y3, 'k') # 4. (y-3.5)**2 = -0.7*(x+2.315) for 3.157 < y < 3.59y4 = np.linspace(3.157, 3.59, 100)x4 = -2.315 - (y4 - 3.5)**2 / 0.7plt.plot(x4, y4, 'k') # 5. y = -8.7*(x+2.3)**2 + 3.63 for -2.25 < x < -2.149x5 = np.linspace(-2.25, -2.149, 100)y5 = -8.7 * (x5 + 2.3)**2 + 3.63plt.plot(x5, y5, 'k') # 6. y = -25*(x+2.007) for 2.93 < y < 3.43y6 = np.linspace(2.93, 3.43, 100)x6 = -2.007 - y6/25plt.plot(x6, y6, 'k') # 7. y = -2.5*(x+0.95) for -2.185 < x < -2.125x7 = np.linspace(-2.185, -2.125, 100)y7 = -2.5 * (x7 + 0.95)plt.plot(x7, y7, 'k') # 8. y = 2*x + 7.47 for 2.91 < y < 3.09y8 = np.linspace(2.91, 3.09, 100)x8 = (y8 - 7.47) / 2plt.plot(x8, y8, 'k') # 9. (y-2.7)**2 = x + 2.32 for 2.654 < y < 2.907y9 = np.linspace(2.654, 2.907, 100)x9 = (y9 - 2.7)**2 - 2.32plt.plot(x9, y9, 'k') # 10. (y-3)**2 = x + 2.44 for 2.652 < y < 2.81y10 = np.linspace(2.652, 2.81, 100)x10 = (y10 - 3)**2 - 2.44plt.plot(x10, y10, 'k') # 11. (y-3)**2 = 0.5*(x+2.414) for 2.886 < y < 3.037y11 = np.linspace(2.886, 3.037, 100)x11 = (y11 - 3)**2 / 0.5 - 2.414plt.plot(x11, y11, 'k') # 12. y = 0.9*x + 5.214 for -2.48 < x < -2.41x12 = np.linspace(-2.48, -2.41, 100)y12 = 0.9 * x12 + 5.214plt.plot(x12, y12, 'k') # 13. (y-3.06)**2 = 0.35*(x+2.51) for 2.86 < y < 3.157y13 = np.linspace(2.86, 3.157, 100)x13 = (y13 - 3.06)**2 / 0.35 - 2.51plt.plot(x13, y13, 'k') # 14. (y-2.84)**2 = -0.07*(x+2.39) for 2.809 < y < 2.86y14 = np.linspace(2.809, 2.86, 100)x14 = -2.39 - (y14 - 2.84)**2 / 0.07plt.plot(x14, y14, 'k') # 15. y = 0.55*x + 4.13 for -2.5735 < x < -2.403x15 = np.linspace(-2.5735, -2.403, 100)y15 = 0.55 * x15 + 4.13plt.plot(x15, y15, 'k') # 16. y = 16*(x+2.64)**2 + 2.63 for -2.654 < x < -2.565x16 = np.linspace(-2.654, -2.565, 100)y16 = 16 * (x16 + 2.64)**2 + 2.63plt.plot(x16, y16, 'k') # 17. y = 1.6*(x+4.3) for -2.774 < x < -2.654x17 = np.linspace(-2.774, -2.654, 100)y17 = 1.6 * (x17 + 4.3)plt.plot(x17, y17, 'k') # 18. y = -0.37*x + 1.35 for 2.42 < y < 2.753y18 = np.linspace(2.42, 2.753, 100)x18 = (1.35 - y18) / 0.37plt.plot(x18, y18, 'k') # 19. y = 7*(x+2.845)**2 + 2.405 for -2.89 < x < -2.774x19 = np.linspace(-2.89, -2.774, 100)y19 = 7 * (x19 + 2.845)**2 + 2.405plt.plot(x19, y19, 'k') # 20. y = 5*x + 21.7 for -3.79 < x < -3.734x20 = np.linspace(-3.79, -3.734, 100)y20 = 5 * x20 + 21.7plt.plot(x20, y20, 'k') # 21. y = -x - 0.7 for -4.028 < x < -3.734x21 = np.linspace(-4.028, -3.734, 100)y21 = -x21 - 0.7plt.plot(x21, y21, 'k') # 22. (y-2.8)**2 = 4*(x+4.1) for 2.8 < y < 3.64y22 = np.linspace(2.8, 3.64, 100)x22 = (y22 - 2.8)**2 / 4 - 4.1plt.plot(x22, y22, 'k') # 23. y = -1.1*x - 0.66 for 3.65 < y < 3.83y23 = np.linspace(3.65, 3.83, 100)x23 = (-y23 - 0.66) / -1.1plt.plot(x23, y23, 'k') # 24. y = -1.4*x - 1.836 for -3.92 < x < -3.717x24 = np.linspace(-3.92, -3.717, 100)y24 = -1.4 * x24 - 1.836plt.plot(x24, y24, 'k') # 25. y = 3*(x+3.5)**2 + 3.22 for -3.72 < x < -3.526x25 = np.linspace(-3.72, -3.526, 100)y25 = 3 * (x25 + 3.5)**2 + 3.22plt.plot(x25, y25, 'k') # 26. Circle: (x+3.49)**2 + (y-3.24)**2 <= 0.0013theta = np.linspace(0, 2*np.pi, 100)r = np.sqrt(0.0013)x26 = -3.49 + r * np.cos(theta)y26 = 3.24 + r * np.sin(theta)plt.fill(x26, y26, 'k') # 27. y = 5.7*(x+3.55)**2 + 3.32 for -3.7 < x < -3.55x27 = np.linspace(-3.7, -3.55, 100)y27 = 5.7 * (x27 + 3.55)**2 + 3.32plt.plot(x27, y27, 'k') # 28. y = 3.32 for -3.55 < x < -3.44x28 = np.linspace(-3.55, -3.44, 100)y28 = np.full_like(x28, 3.32)plt.plot(x28, y28, 'k') # 29. y = -x - 0.11 for -3.483 < x < -3.39x29 = np.linspace(-3.483, -3.39, 100)y29 = -x29 - 0.11plt.plot(x29, y29, 'k') # 30. (y-3.4)**2 = 0.06*(x+3.492) for 3.375 < y < 3.437y30 = np.linspace(3.375, 3.437, 100)x30 = (y30 - 3.4)**2 / 0.06 - 3.492plt.plot(x30, y30, 'k') # 31. y = 0.1*x + 3.784 for -3.47 < x < -3.4x31 = np.linspace(-3.47, -3.4, 100)y31 = 0.1 * x31 + 3.784plt.plot(x31, y31, 'k') # 32. y = -14*(x+3.5)**2 + 3.6 for -3.48 < x < -3.396x32 = np.linspace(-3.48, -3.396, 100)y32 = -14 * (x32 + 3.5)**2 + 3.6plt.plot(x32, y32, 'k') # 33. y = -0.45*x + 2.03 for 3.596 < y < 3.826y33 = np.linspace(3.596, 3.826, 100)x33 = (2.03 - y33) / 0.45plt.plot(x33, y33, 'k') # 34. (y-3.86)**2 = 0.06*(x+4.096) for 3.831 < y < 3.89y34 = np.linspace(3.831, 3.89, 100)x34 = (y34 - 3.86)**2 / 0.06 - 4.096plt.plot(x34, y34, 'k') # 35. y = -0.35*x + 2.48 for -4.019 < x < -3.5x35 = np.linspace(-4.019, -3.5, 100)y35 = -0.35 * x35 + 2.48plt.plot(x35, y35, 'k') # 36. y = -0.05*x + 3.686 for 3.887 < y < 3.89y36 = np.linspace(3.887, 3.89, 100)x36 = (3.686 - y36) / 0.05plt.plot(x36, y36, 'k') # 37. y = -2*(x+3.61)**2 + 3.73 for -3.497 < x < -3.333x37 = np.linspace(-3.497, -3.333, 100)y37 = -2 * (x37 + 3.61)**2 + 3.73plt.plot(x37, y37, 'k') # 38. y = 10*(x+3.32)**2 + 3.573 for -3.332 < x < -3.253x38 = np.linspace(-3.332, -3.253, 100)y38 = 10 * (x38 + 3.32)**2 + 3.573plt.plot(x38, y38, 'k') # 39. (y-3.6)**2 = 1.3*(x+3.25) for 3.621 < y < 4.339y39 = np.linspace(3.621, 4.339, 100)x39 = (y39 - 3.6)**2 / 1.3 - 3.25plt.plot(x39, y39, 'k') # 40. y = -3*x - 8 for 3.697 < y < 3.8y40 = np.linspace(3.697, 3.8, 100)x40 = (-y40 - 8) / -3plt.plot(x40, y40, 'k') # 41. y = -10*x - 34.4 for 3.65 < y < 3.744y41 = np.linspace(3.65, 3.744, 100)x41 = (-y41 - 34.4) / -10plt.plot(x41, y41, 'k') # 42. (y-3.4)**2 = 2*(x+3.76) for 3.57 < y < 3.702y42 = np.linspace(3.57, 3.702, 100)x42 = (y42 - 3.4)**2 / 2 - 3.76plt.plot(x42, y42, 'k') # 43. y = 2*x + 11.6 for -3.88 < x < -3.69x43 = np.linspace(-3.88, -3.69, 100)y43 = 2 * x43 + 11.6plt.plot(x43, y43, 'k') # 44. (y-3.7)**2 = 2.6*(x+3.79) for 3.8 < y < 4.22y44 = np.linspace(3.8, 4.22, 100)x44 = (y44 - 3.7)**2 / 2.6 - 3.79plt.plot(x44, y44, 'k') # 45. (y-4.2)**2 = 2.7*(x+3.69) for 3.745 < y < 4.21y45 = np.linspace(3.745, 4.21, 100)x45 = (y45 - 4.2)**2 / 2.7 - 3.69plt.plot(x45, y45, 'k') # 46. (y-4.35)**2 = (x+3.65) for 3.774 < y < 4.295y46 = np.linspace(3.774, 4.295, 100)x46 = (y46 - 4.35)**2 - 3.65plt.plot(x46, y46, 'k') # 47. y = 2.3*(x+3.2)**2 + 3.85 for -3.639 < x < -3.294x47 = np.linspace(-3.639, -3.294, 100)y47 = 2.3 * (x47 + 3.2)**2 + 3.85plt.plot(x47, y47, 'k') # 48. y = -0.7*(x+3.5)**2 + 4.32 for -3.56 < x < -3.04x48 = np.linspace(-3.56, -3.04, 100)y48 = -0.7 * (x48 + 3.5)**2 + 4.32plt.plot(x48, y48, 'k') # 49. (y-3.77)**2 = -2*(x+3.22) for 3.077 < y < 3.57y49 = np.linspace(3.077, 3.57, 100)x49 = -3.22 - (y49 - 3.77)**2 / 2plt.plot(x49, y49, 'k') # 50. (y-4)**2 = -2.2*(x+3.06) for 3.067 < y < 3.514y50 = np.linspace(3.067, 3.514, 100)x50 = -3.06 - (y50 - 4)**2 / 2.2plt.plot(x50, y50, 'k') # 51. y = -6*x - 15.44 for 3.254 < y < 3.522y51 = np.linspace(3.254, 3.522, 100)x51 = (-y51 - 15.44) / -6plt.plot(x51, y51, 'k') # 52. y = 3*x + 12.57 for 3.018 < y < 3.389y52 = np.linspace(3.018, 3.389, 100)x52 = (y52 - 12.57) / 3plt.plot(x52, y52, 'k') # 53. y = 2.2*x + 10 for 3.015 < y < 3.539y53 = np.linspace(3.015, 3.539, 100)x53 = (y53 - 10) / 2.2plt.plot(x53, y53, 'k') # 54. y = -9*x - 24.5 for 2.87 < y < 3.22y54 = np.linspace(2.87, 3.22, 100)x54 = (-y54 - 24.5) / -9plt.plot(x54, y54, 'k') # 55. (y-3.3)**2 = -0.8*(x+2.81) for 2.87 < y < 3.3y55 = np.linspace(2.87, 3.3, 100)x55 = -2.81 - (y55 - 3.3)**2 / 0.8plt.plot(x55, y55, 'k') # 56. y = 15*(x+3.03) for 3.015 < y < 3.667y56 = np.linspace(3.015, 3.667, 100)x56 = y56/15 - 3.03plt.plot(x56, y56, 'k') # 57. y = 3*x + 11.5 for -2.828 < x < -2.786x57 = np.linspace(-2.828, -2.786, 100)y57 = 3 * x57 + 11.5plt.plot(x57, y57, 'k') # 58. (y-3.18)**2 = 0.25*(x+2.78) for 3.095 < y < 3.23y58 = np.linspace(3.095, 3.23, 100)x58 = (y58 - 3.18)**2 / 0.25 - 2.78plt.plot(x58, y58, 'k') # 59. y = 4*x + 14.23 for -2.739 < x < -2.7x59 = np.linspace(-2.739, -2.7, 100)y59 = 4 * x59 + 14.23plt.plot(x59, y59, 'k') # 60. (y-3.36)**2 = 2*(x+2.7) for 3.43 < y < 3.77y60 = np.linspace(3.43, 3.77, 100)x60 = (y60 - 3.36)**2 / 2 - 2.7plt.plot(x60, y60, 'k') # 61. y = 2.8*(x+3.962) for 3.77 < y < 3.98y61 = np.linspace(3.77, 3.98, 100)x61 = y61/2.8 - 3.962plt.plot(x61, y61, 'k') # 62. y = (x+2.9)**2 + 3.39 for -2.7 < x < -2.37x62 = np.linspace(-2.7, -2.37, 100)y62 = (x62 + 2.9)**2 + 3.39plt.plot(x62, y62, 'k') # 63. y = 1.4*(x+2.7)**2 + 3.4 for -2.7 < x < -2.287x63 = np.linspace(-2.7, -2.287, 100)y63 = 1.4 * (x63 + 2.7)**2 + 3.4plt.plot(x63, y63, 'k') # 64. y = -0.6*x + 1.95 for -2.55 < x < -2.45x64 = np.linspace(-2.55, -2.45, 100)y64 = -0.6 * x64 + 1.95plt.plot(x64, y64, 'k') # 65. (y-3.49)**2 = 0.02*(x+2.554) for 3.48 < y < 3.506y65 = np.linspace(3.48, 3.506, 100)x65 = (y65 - 3.49)**2 / 0.02 - 2.554plt.plot(x65, y65, 'k') # 66. y = -7*(x+2.515)**2 + 3.51 for -2.54 < x < -2.42x66 = np.linspace(-2.54, -2.42, 100)y66 = -7 * (x66 + 2.515)**2 + 3.51plt.plot(x66, y66, 'k') # 67. y = 60*(x+2.441)**2 + 3.42 for -2.441 < x < -2.42x67 = np.linspace(-2.441, -2.42, 100)y67 = 60 * (x67 + 2.441)**2 + 3.42plt.plot(x67, y67, 'k') # 68. y = 3.42 for -2.45 < x < -2.441x68 = np.linspace(-2.45, -2.441, 100)y68 = np.full_like(x68, 3.42)plt.plot(x68, y68, 'k') # 69. y = -2.8*(x+2.71)**2 + 3.24 for -2.77 < x < -2.63x69 = np.linspace(-2.77, -2.63, 100)y69 = -2.8 * (x69 + 2.71)**2 + 3.24plt.plot(x69, y69, 'k') # 70. y = -12*(x+2.64)**2 + 3.223 for -2.63 < x < -2.548x70 = np.linspace(-2.63, -2.548, 100)y70 = -12 * (x70 + 2.64)**2 + 3.223plt.plot(x70, y70, 'k') # 71. y = 3.25 for -2.77 < x < -2.65x71 = np.linspace(-2.77, -2.65, 100)y71 = np.full_like(x71, 3.25)plt.plot(x71, y71, 'k') # 72. y = -3.8*(x+2.7)**2 + 3.26 for -2.65 < x < -2.56x72 = np.linspace(-2.65, -2.56, 100)y72 = -3.8 * (x72 + 2.7)**2 + 3.26plt.plot(x72, y72, 'k') # 73. y = -2*(x+2.64)**2 + 3.32 for -2.64 < x < -2.52x73 = np.linspace(-2.64, -2.52, 100)y73 = -2 * (x73 + 2.64)**2 + 3.32plt.plot(x73, y73, 'k') # 74. y = 1.2*x + 6.32 for 3.27 < y < 3.293y74 = np.linspace(3.27, 3.293, 100)x74 = (y74 - 6.32) / 1.2plt.plot(x74, y74, 'k') # 75. y = -25*(x+2.65)**2 + 3.21 for -2.689 < x < -2.619x75 = np.linspace(-2.689, -2.619, 100)y75 = -25 * (x75 + 2.65)**2 + 3.21plt.plot(x75, y75, 'k') # 76. (y-3.24)**2 = -0.5*(x+2.61) for 3.028 < y < 3.184y76 = np.linspace(3.028, 3.184, 100)x76 = -2.61 - (y76 - 3.24)**2 / 0.5plt.plot(x76, y76, 'k') # 77. (y-3.09)**2 = 0.27*(x+2.715) for 3.027 < y < 3.139y77 = np.linspace(3.027, 3.139, 100)x77 = (y77 - 3.09)**2 / 0.27 - 2.715plt.plot(x77, y77, 'k') # 78. Circle: (x+2.692)**2 + (y-3.152)**2 <= 0.0003r78 = np.sqrt(0.0003)x78 = -2.692 + r78 * np.cos(theta)y78 = 3.152 + r78 * np.sin(theta)plt.fill(x78, y78, 'k') # 79. Ellipse: (x+2.69)**2/0.0006 + (y-3.07)**2/0.0003 <= 1ell79 = Ellipse(xy=(-2.69, 3.07), width=2*np.sqrt(0.0006), height=2*np.sqrt(0.0003), angle=0, color='k')plt.gca().add_patch(ell79) # 80. Rotated Ellipse: (0.707(x+2.69)+0.707(y-3.07))**2/0.0006 +# (-0.707(x+2.69)+0.707(y-3.07))**2/0.0003 <= 1ell80 = Ellipse(xy=(-2.69, 3.07), width=2*np.sqrt(0.0006), height=2*np.sqrt(0.0003), angle=45, color='k')plt.gca().add_patch(ell80) # 81. Ellipse: (x+2.69)**2/0.0008 + (y-3.117)**2/0.0004 <= 1ell81 = Ellipse(xy=(-2.69, 3.117), width=2*np.sqrt(0.0008), height=2*np.sqrt(0.0004), angle=0, color='k')plt.gca().add_patch(ell81) # 82. Rotated Ellipse: (0.707(x+2.69)+0.707(y-3.117))**2/0.0008 +# (-0.707(x+2.69)+0.707(y-3.117))**2/0.0004 <= 1ell82 = Ellipse(xy=(-2.69, 3.117), width=2*np.sqrt(0.0008), height=2*np.sqrt(0.0004), angle=45, color='k')plt.gca().add_patch(ell82) # 83. y = -2.5*(x+2.8)**2 + 2.704 for -2.768 < x < -2.674x83 = np.linspace(-2.768, -2.674, 100)y83 = -2.5 * (x83 + 2.8)**2 + 2.704plt.plot(x83, y83, 'k') # 84. y = -x - 0.07 for 2.638 < y < 2.701y84 = np.linspace(2.638, 2.701, 100)x84 = -y84 - 0.07plt.plot(x84, y84, 'k') # 85. y = 0.8*x + 4.803 for -2.707 < x < -2.674x85 = np.linspace(-2.707, -2.674, 100)y85 = 0.8 * x85 + 4.803plt.plot(x85, y85, 'k') # 86. (y-3.6)**2 = 1.4*(x+3.93) for 3.283 < y < 3.626y86 = np.linspace(3.283, 3.626, 100)x86 = (y86 - 3.6)**2 / 1.4 - 3.93plt.plot(x86, y86, 'k') # 87. (y-3.5)**2 = (x+3.79) for 3.271 < y < 3.469y87 = np.linspace(3.271, 3.469, 100)x87 = (y87 - 3.5)**2 - 3.79plt.plot(x87, y87, 'k') # 88. y = -2*x - 4.04 for 3.174 < y < 3.314y88 = np.linspace(3.174, 3.314, 100)x88 = (-y88 - 4.04) / -2plt.plot(x88, y88, 'k') # 89. y = -0.5*x + 1.37 for -3.69 < x < -3.607x89 = np.linspace(-3.69, -3.607, 100)y89 = -0.5 * x89 + 1.37plt.plot(x89, y89, 'k') # 90. x = -3.69 for 3.103 < y < 3.214y90 = np.linspace(3.103, 3.214, 100)x90 = np.full_like(y90, -3.69)plt.plot(x90, y90, 'k') # 91. y = -0.5*x + 1.25 for -3.752 < x < -3.69x91 = np.linspace(-3.752, -3.69, 100)y91 = -0.5 * x91 + 1.25plt.plot(x91, y91, 'k') # 92. x = -3.752 for 3.052 < y < 3.126y92 = np.linspace(3.052, 3.126, 100)x92 = np.full_like(y92, -3.752)plt.plot(x92, y92, 'k') # 93. (y-2.93)**2 = 3*(x+3.84) for 2.836 < y < 3.107y93 = np.linspace(2.836, 3.107, 100)x93 = (y93 - 2.93)**2 / 3 - 3.84plt.plot(x93, y93, 'k') # 94. (y-2.7)**2 = 2.5*(x+3.84) for 2.83 < y < 3.08y94 = np.linspace(2.83, 3.08, 100)x94 = (y94 - 2.7)**2 / 2.5 - 3.84plt.plot(x94, y94, 'k') # 95. y = -1.5*x - 1.17 for -3.743 < x < -3.645x95 = np.linspace(-3.743, -3.645, 100)y95 = -1.5 * x95 - 1.17plt.plot(x95, y95, 'k') # 96. y = -5*(x+3.83)**2 + 4.48 for -3.95 < x < -3.745x96 = np.linspace(-3.95, -3.745, 100)y96 = -5 * (x96 + 3.83)**2 + 4.48plt.plot(x96, y96, 'k') # 97. y = 1.5*x + 10.4 for 3.658 < y < 4.277y97 = np.linspace(3.658, 4.277, 100)x97 = (y97 - 10.4) / 1.5plt.plot(x97, y97, 'k') # 98. (y-4)**2 = 0.7*(x+4.19) for 4.276 < y < 4.41y98 = np.linspace(4.276, 4.41, 100)x98 = (y98 - 4)**2 / 0.7 - 4.19plt.plot(x98, y98, 'k') # 99. (y-2.7)**2 = 3*(x+4.8) for 3.245 < y < 3.653y99 = np.linspace(3.245, 3.653, 100)x99 = (y99 - 2.7)**2 / 3 - 4.8plt.plot(x99, y99, 'k') # 100. (y-2.6)**2 = 1.8*(x+4.9) for 2.423 < y < 3.04y100 = np.linspace(2.423, 3.04, 100)x100 = (y100 - 2.6)**2 / 1.8 - 4.9plt.plot(x100, y100, 'k') # 101. y=2.3x+14.06 {3.04
图形


总结
还是需要感谢B站UP主:WalkingStar。非常的厉害,我只是在此基础上进行的二创,节省了很多的时间。
浙公网安备 33010602011771号