生活随笔
收集整理的这篇文章主要介绍了
笛卡尔心形曲线
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
笛卡尔的爱情故事相比大家都已经非常熟悉了,在传递给公主的第十八封信里面隐藏着这个函数
(x2+y2)3=x2y3(x^2+y^2)^3 = x^2y^3 (x2+y2)3=x2y3
利用python就可以将这个函数给画出来,当然首先得解出这个函数。
import matplotlib
.pyplot
as plt
import numpy
as np
plt
.style
.use
('dark_background')
fig
, ax
= plt
.subplots
(figsize
=(5,5))
ax
.spines
['right'].set_color
('none')
ax
.spines
['top'].set_color
('none')
ax
.spines
['bottom'].set_color
('white')
ax
.spines
['left'].set_color
('white')ax
.xaxis
.set_ticks_position
('bottom')
ax
.spines
['bottom'].set_position
(('data',0))
ax
.yaxis
.set_ticks_position
('left')
ax
.spines
['left'].set_position
(('data',0))ax
.set_yticks
([-1.0,-0.5,0.5,1.0,1.5])
ax
.set_xticks
([-1.0,-0.5,0.5,1.0])plt
.title
('Cardioid', fontsize
=24)
x
= np
.linspace
(-1,1,200)
y1
= np
.sqrt
(1-np
.power
(x
, 2)) + np
.power
(np
.square
(x
), 0.33)
y2
= -np
.sqrt
(1-np
.power
(x
, 2)) + np
.power
(np
.square
(x
), 0.33)
plt
.plot
(x
, y1
, color
='#FFC0CB')
plt
.plot
(x
, y2
, color
='#FFC0CB')
plt
.show
()
具体的图像就是下面这幅了。
总结
以上是生活随笔为你收集整理的笛卡尔心形曲线的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。