Home > other >  Python matplotlib drawing hearts
Python matplotlib drawing hearts

Time:09-23

Leading into the related modules, completes the set ahead of time,
Set the update callback function, update picture,
Set the generator function, every time used to generate the data needed to
The last window display,
Change the speed of a generated to change the size of the heart, of course you can also set a different color here I used the red, renderings below go liao sister

CodePudding user response:


How to remove the coordinate axis

CodePudding user response:

Hello, you can set the axis transparent, can't see

CodePudding user response:

The import numpy as np
The import matplotlib. Pyplot as mp
The import matplotlib. Animation as ma

X=np. Linspace (1.81, 1.81, 1000)
Mp. Xlim (x.m in () * 1.2, x.m ax () * 1.2)
Ax=mp. Gca ()
Ax. Spines [' top '] set_color (' none ')
Ax. Spines [' right '] set_color (' none ')
Ax. Spines [' left '] set_position ((' date ', 0))
Ax. Spines [' bottom '] set_position ((' date ', 0))

Def update (y) :
Mp. The plot (x, y, color='red')
Mp. The plot (x, y, color='red')
Def the generator () :
A=2
While True:
Y=x (2/3) + np. * * SQRT (0.9 * 3.3 * * x (2)) * np in sin (a * np. PI * x)
Yield y
A +=0.1

Anim=ma. FuncAnimation (mp. GCF (), update, the generator, the interval=5)
Mp. The show ()



Copy the code is copied wrong, save the child

CodePudding user response:

  • Related