import numpy as np import matplotlib.pyplot as plt def descartes(ax, ran_x, ran_y, ax_title,x_label = "x", y_label = "y"): ax.set_xlabel(x_label, fontsize = 12) ax.set_ylabel(y_label, fontsize = 12) ax.set_xlim(ran_x[0], ran_x[1]) ax.set_ylim(ran_y[0], ran_y[1]) ax.set_title(ax_title, fontsize = 14) ax.grid() ax.axhline(0, color = "black") ax.axvline(0, color = "black") fig = plt.figure(figsize = (5, 5)) ax = fig.add_subplot(111) title1 = "Kyoto University 2024 Math qu.2 NO1" last_n=50 zz=[[]] xx=[[]] yy=[[]] for x1 in np.linspace(-2,2,last_n): for x2 in np.linspace(-2,2,last_n): if x1**2+x2**2 <= 4: xx.append([x1,x2]) del xx[0] for t in np.linspace(0,2*np.pi,last_n): yy.append([3*np.cos(t)+8,3*np.sin(t)+6]) del yy[0] for i in range(len(xx)): for j in range(len(yy)): zz.append([(xx[i][0]+yy[j][0])/2,(xx[i][1]+yy[j][1])/2]) del zz[0] zz=np.array(zz) z1=zz[:,0] z2=zz[:,1] descartes(ax, [-1, 8], [-1, 8],title1) ax.scatter(z1 ,z2 , color="red",s=5) plt.show()