Python 我必须用函数画出一个半圆形。我的代码在绘图中没有显示任何内容

Python 我必须用函数画出一个半圆形。我的代码在绘图中没有显示任何内容,python,python-3.x,Python,Python 3.x,正如我在标题中所说,当我运行我的程序时,绘图中没有显示任何内容。我不确定我的问题是来自courbeFerme功能还是转子下功能。整个上午都在努力解决这个问题,但没有结果。提前非常感谢您的回答 import numpy as np import matplotlib.pyplot as plt n=0 def courbeFerme(R,r): #Cette fonction assure qu'on a une courbe fermé m=0 n=(r/(R-r))*

正如我在标题中所说,当我运行我的程序时,绘图中没有显示任何内容。我不确定我的问题是来自courbeFerme功能还是转子下功能。整个上午都在努力解决这个问题,但没有结果。提前非常感谢您的回答

import numpy as np
import matplotlib.pyplot as plt

n=0
def courbeFerme(R,r):
    #Cette fonction assure qu'on a une courbe fermé
    m=0
    n=(r/(R-r))*m
    if (R in range(0,1000)) and (r in range(0,1000)):
        while ((r/(R-r))*m).is_integer()==0: #Tant que n n'est pas un entier refaire boucle
            m+=1
            n=(r/(R-r))*m           
        return n


def hypotrochoide(R,r,d,phi0=0,color='k'):  #Tracer hypotrochoide
    
    angle=np.linspace(0,2*np.pi*courbeFerme(R,r),2000) 
    
    phi0=np.radians(float(phi0)) #angle de depart dans le petit cercle
    
    #les equations de hypotrochoide
    x=(R-r)*np.cos(angle)+d*np.cos(-((R-r)/r)*angle+phi0)
    y=(R-r)*np.sin(angle)+d*np.sin(-((R-r)/r)*angle+phi0)
    
    #graph
    plt.axis('off')
    plt.axis('equal')
    plt.plot(x,y,color)
    plt.show()
    
    return

hypotrochoide(264,110,80,0,'midnightblue')
hypotrochoide(252,105,80,20,'royalblue')
hypotrochoide(240,100,80,40,'yellowgreen')
hypotrochoide(252,105,80,60,'royalblue')
hypotrochoide(60,35,20,0,'olive')
hypotrochoide(70,15,10,0,'midnightblue')

您的while子句的条件有问题。您永远不会进入while循环,因为您的条件始终为真:
m==0
so
((r/(r-r))*m==0
so
((r/(r-r))*m)。is_integer()为真

要得到所需的结果,需要将函数开头的值m更改为1