fig = plt.figure()
ax = fig.add_subplot(111)
def func_plot():
alpha1 = 0.25 # np.random.randint(0, 10) / 10
rect1 = patches.Rectangle((-0.50, -0.50), 1, 1, color='g', alpha = alpha1)
#rect2 = patches.Rectangle((0, -0.50), 0.5, 1, color='red', alpha = 0.25)
for a, b in zip([1, 1, 3, 3],[1, 3, 1, 3]):
circle_ = patches.Circle((a/4-0.5, b/4-.5), radius= 2**0.5/4,
color='g', alpha = alpha1 * .8)
ax.add_patch(circle_)
#circle2 = patches.Circle((+0.5, 0), radius= 2**0.5/2, color='green', alpha = 0.5)
ax.add_patch(rect1)
#ax.add_patch(rect2)
#fig = plt.figure()
# ax = fig.add_subplot(111)
func_plot()
#ax.add_patch(circle2)
plt.xlim([-1, 1])
plt.ylim([-1, 1])
plt.axis('equal')
plt.grid()
Last active
September 17, 2022 19:01
-
-
Save jupihes/b475a0fd3efb91e063b81fffecb32209 to your computer and use it in GitHub Desktop.
Riddle_classic of can-you-cover-the-baking-sheet-with-cookies
import matplotlib
from matplotlib import pyplot as plt, patches
fig = plt.figure()
ax = fig.add_subplot()
def func_plot():
alpha1 = 0.5 # np.random.randint(0, 10) / 10
rect1 = patches.Rectangle((-0.50, -0.50), 1, 1, color='g', alpha = alpha1/5)
#rect2 = patches.Rectangle((0, -0.50), 0.5, 1, color='red', alpha = 0.25)
for a, b in zip([0, -.5, 0, .5, 0],[0.5, 0, 0, 0, -.5]):
circle_ = patches.Circle((a, b), radius= 0.5,
color='m', alpha = alpha1 * .8)
ax.add_patch(circle_)
ax.add_patch(rect1)
ax = fig.add_subplot(111)
func_plot()
plt.xlim([-1, 1])
plt.ylim([-1, 1])
plt.axis('equal')
plt.grid()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/jupihes/b475a0fd3efb91e063b81fffecb32209#file-riddle_classic_5c-md
