我确定这是一个基本问题,但我试图从半长轴(a),半短轴(b)和椭圆的角度绘制三个椭圆的图旋转(p)。
我有a,b,旋转存储在三个独立的数组中 a = [a1,a2,a3],b = [b1,b2,b3],p = [p1,p2,p3]。
我是matplotlib的新手,我不知道如何通过这三个参数来制作三个独立的椭圆图。
到目前为止,这是我的代码:
int isElementInBinaryTree(BinaryTreeNode *root, int search_item) {
if(root) {
if(search_item == root -> data) return 1;
isElementInBinaryTree(root -> left, search_item);
isElementInBinaryTree(root -> right, search_item);
}
return 0;
}
答案 0 :(得分:1)
这会在同一图中创建3个椭圆:
for w, h, angle in zip(a, b, p):
ellipse = Ellipse(xy=(0,0), width=w, height=h, angle=angle)
ax.add_patch(ellipse)
plt.axis('scaled')
plt.show()
要将每个椭圆放在单独的子图中,请执行以下操作:
fig, axes = plt.subplots(len(a), sharex=True, sharey=True)
for ax, w, h, angle in zip(axes, a, b, p):
ellipse = Ellipse(xy=(0,0), width=w, height=h, angle=angle)
ax.add_patch(ellipse)
plt.axis('auto')
plt.show()