2024-04-26 07:40:58 发布
网友
我是python新手,我正在尝试从原始数据重新排列矩形。我正在使用装箱算法,我想用下面的颜色对它进行排序。需要帮忙吗
现在输出:
预期产出:
代码中有一些小的更改,请按照以下代码执行一次:
import matplotlib.pyplot as plt from matplotlib.patches import Rectangle fig = plt.figure() ax = fig.add_subplot(111) temp_y=0 i=0 layout_height = 300 layout_width = 300 ax.set_xlim([0, layout_height]) ax.set_ylim([0, layout_width]) area_height = [80, 75, 50, 60, 52, 72, 100, 120, 150] area_width = [50, 46, 52, 52, 50, 48, 25, 40, 48] for (i,j) in zip(area_height, area_width): print(i,j) ax.add_patch(Rectangle((0, temp_y), float(j), float(i),edgecolor ='black',facecolor = 'red')) temp_y = temp_y + float(i)
代码中有一些小的更改,请按照以下代码执行一次:
相关问题 更多 >
编程相关推荐