用python画玫瑰花

news/2025/2/3 23:54:05/

用python画玫瑰花

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(8,8))
ax = fig.gca(projection='3d')
# 将相位向后移动了6*pi
[x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 20 * np.pi + 4*np.pi)
p = (np.pi / 2) * np.exp(-t / (8 * np.pi))
# 添加边缘扰动
change = np.sin(15*t)/150
# 将t的参数减少,使花瓣的角度变大
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))
h = u * (x * np.cos(p) - y * np.sin(p))
c= plt.get_cmap('Reds')
surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1,cmap= c, linewidth=0, antialiased=True)
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])plt.show()

效果图
在这里插入图片描述


http://www.ppmy.cn/news/712732.html

相关文章

Python玫瑰花绘制

刚开始学Python,画个玫瑰花练练手,正好今天也是情人节 我自认为还是挺好看的,感觉比我搜到的那几个画出来的强 代码如下 import turtle as t t.setup(1100,1000) t.hideturtle() t.speed(11) t.penup() t.goto(50,-450) t.pensize(5) t.pen…

输出四叶玫瑰花数

四叶玫瑰数&#xff1a;一个4位正整数等于其各个数字的4次方之和&#xff0c;则称为四叶玫瑰数。 #include<stdio.h> #include<math.h> int main() {int i,j,a,b,c,d;for(i1000;i<9999;i){ai%10;bi/10%10;ci/100%10;di/1000;jpow(a,4)pow(b,4)pow(c,4)pow(d,4)…

python玫瑰花代码

如下&#xff1a; ​Created on Nov 18, 2017 author: QiZhaoimport turtle# 设置初始位置 turtle.penup() turtle.left(90) turtle.fd(200) turtle.pendown() turtle.right(90)# 花蕊 turtle.fillcolor("red") turtle.begin_fill() turtle.circle(10,180) turtle.c…

Python作画玫瑰花

import turtle# 设置初始位置 turtle.penup() turtle.left(90) turtle.fd(200) turtle.pendown() turtle.right(90)# 花蕊 turtle.fillcolor("red") turtle.begin_fill() turtle.circle(10,180) turtle.circle(25,110) turtle.left(50) turtle.circle(60,45) turtle.…

玫瑰花的制作(代码+RGB)

玫瑰花 最近在自己的文件夹中发现了一个小程序&#xff0c;打开之后发现不得了&#xff0c;程序的内容居然是一朵用代码和RGB调色&#xff0c;再利用数学公式制作的玫瑰花&#xff0c;效果十分惊艳。 下面直接上图&#xff1a; 图片貌似贴的有点大了&#xff08;匿&#xff1a;…

富贵春国藏

浓香型酒-富贵春国藏&#xff0c;是生态、原料、工艺对中国白酒风味造成影响的综合表达和精炼诠释。在众多香型白酒之中&#xff0c;浓香型白酒是我国传统白酒酿造技艺传承的典型代表之一&#xff0c;深受广大消费者的喜爱。据统计&#xff0c;目前浓香型白酒的市场占有率仍超6…

Python画玫瑰花

在参考了https://blog.csdn.net/zaq0123/article/details/78573186/这篇博客 我自己对代码加了一些修改与注释 代码如下 import turtle# 设置初始位置 turtle.penup() # 提起画笔 turtle.left(90) # 逆时针旋转九十度 turtle.fd(200) # 向前移动一段距离 fdforward turtle.…

富贵吉祥,艺术家孙长英笔下的牡丹

在孙长英的绘画作品中&#xff0c;牡丹的形象是最为经典的。她的画作&#xff0c;不仅是传统笔墨的展示&#xff0c;更多的是她的表现力和想象力在其中得到了充分的彰显和发挥。孙长英笔下的牡丹雍容华贵&#xff0c;或枝繁叶茂&#xff0c;姹紫嫣红&#xff0c;或水墨淋漓&…