python - 如何用pylab画一颗心

标签 python math numpy matplotlib

如何用pylab画一颗心?我用谷歌搜索了绘制图片的方法,但我想知道如何用 pylab 绘制它。有人可以帮忙吗?图片应该看起来像this :

3D Heart

最佳答案

在其他解决方案中使用链接公式:

import pylab
x = scipy.linspace(-2,2,1000)
y1 = scipy.sqrt(1-(abs(x)-1)**2)
y2 = -3*scipy.sqrt(1-(abs(x)/2)**0.5)
pylab.fill_between(x, y1, color='red')
pylab.fill_between(x, y2, color='red')
pylab.xlim([-2.5, 2.5])
pylab.text(0, -0.4, 'Stack Overflow', fontsize=24, fontweight='bold',
           color='white', horizontalalignment='center')
pylab.savefig('heart.png')

heart

关于python - 如何用pylab画一颗心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4478078/

相关文章:

python - 提高加权移动平均过滤函数的运行时间?

python - 按另一列提取行最大值组

python - 在python中下载文件

python - pip install MySql-python==1.2.4 在 Ubuntu 12.04 上失败

math - 代数表示代码

python - asfortranarray 中的运行时警告

python - 使用 Python os.system 将 MySQL 数据库导出到 sql 文件

javascript - 如何计算 Canvas 中旋转形状的橡皮筋坐标 - javascript

java - 相对于 x 轴运动镜像

python - 计算最接近的数字numpy