当前位置:网站首页>Valentine's day, send you a little red flower~
Valentine's day, send you a little red flower~
2022-07-03 17:57:00 【Xia Xiaoyou】
List of articles
Preface
stay github See an interesting code on , It's Valentine's Day , Share with you ^_^
1. in early puberty
3D The drawing of the model requires grid points , About the role of grid points , stay This blog Has been introduced in , No more details here .
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
# Moved the phase back 6*pi
x = np.linspace(0, 1, num=30)
t = np.linspace(0, 1, num=1200) * 20 * np.pi + 4 * np.pi
x, t = np.meshgrid(x, t)
p = 0.5 * np.pi * np.exp(-t / (8 * np.pi))
# Add edge perturbation
change = np.sin(15 * t) / 150
# take t The number of parameters is reduced , Increase the angle of the petals
u = 1 - (1 - np.mod(3.3 * t, 2 * np.pi) / np.pi)**4 / 2 + change
y = 2 * (x**2 - x)**2 * np.sin(p)
r = u * (x * np.sin(p) + y * np.cos(p)) * 1.5
h = u * (x * np.cos(p) - y * np.sin(p))
# PiYG_r
# RdBu_r
surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h,
rstride=1, cstride=1, cmap=plt.cm.RdPu_r)
plt.savefig('img/img1.png')
plt.show()



2. Beating its China
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
# plt.axis('off')
x = np.linspace(0, 1, num=30)
t = np.linspace(0, 1, num=1200) * 50 * np.pi - 4 * np.pi
x, t = np.meshgrid(x, t)
p = 0.5 * np.pi * np.exp(-t / (8 * np.pi))
change = np.sin(20 * t) / 50
u = 1 - (1 - np.mod(3.3 * t, 2 * np.pi) / np.pi)**4 / 2 + change
y = 2 * (x**2 - x)**2 * np.sin(p)
r = u * (x * np.sin(p) + y * np.cos(p)) * 1.5
h = u * (x * np.cos(p) - y * np.sin(p))
ax = ax.plot_surface(r * np.cos(t), r * np.sin(t), h,
rstride=1, cstride=1, cmap=plt.cm.RdPu_r)
plt.savefig('img/img2.png')
plt.show()



of
mpl_toolkits.mplot3dYou can refer to Official documents ;
For more color combinations, please refer to
matplotlibOfcolormapThe official manual .
边栏推荐
- SSL / bio pour OpenSSL Get FD
- SQL injection database operation foundation
- Embedded-c language-7
- (8) HS corner detection
- Records of long objects and long judgments in the stream of list
- Redis on local access server
- Automata and automatic line of non-standard design
- [vscode] convert tabs to spaces
- Analysis report on production and marketing demand and investment forecast of China's PVC industry from 2021 to 2026
- 【统信UOS】扫描仪设备管理驱动安装
猜你喜欢

模块九作业

聊聊支付流程的设计与实现逻辑

Vs2013 has blocked the installer, and ie10 needs to be installed

Redis on local access server

STM32实现74HC595控制

Interviewer: why is the value nil not equal to nil?

Embedded-c language-7

Classroom attendance system based on face recognition tkinter+openpyxl+face_ recognition

PHP MySQL inserts data

Wechat applet for the first time
随机推荐
Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method
MySQL has been stopped in the configuration interface during installation
ES6类的继承
PHP MySQL reads data
PHP MySQL order by keyword
Leetcode Valentine's Day Special - looking for a single dog
Records of long objects and long judgments in the stream of list
Embedded-c language-7
Enterprise custom form engine solution (XI) -- form rule engine 1
A. Odd Selection【BruteForce】
聊聊支付流程的设计与实现逻辑
How to purchase Google colab members in China
i++与++i的区别:通俗易懂的讲述他们的区别
The gbase 8A database does not support the DB2 function value (column_name, 0) cluster syntax
模块九作业
Leetcode 108 converts an ordered array into a binary search tree -- recursive method
Create a new file from templates with bash script - create new file from templates with bash script
1146_ SiCp learning notes_ exponentiation
Redis core technology and practice - learning notes (VIII) sentinel cluster: sentinel hung up
[mathematical logic] equivalent calculus and reasoning calculus of predicate logic (individual word | predicate | quantifier | predicate logic formula | two basic formulas | proposition symbolization