creating handle to objects in 2D/3D plot and manip

2019-09-13 00:05发布

问题:

In Matlab, it is possible to create handle for say a square.

square = [2,-2; 2,2;-2,2;-2,-2];
sq_ = fill(square(:,1), square(:,2), 'g');

And then we can manipulate the object, say translate it from origin where it was to (17,81).

set(sq_, 'X', 17+square(:,1),'Y', 81+square(:,2));

The entire code to implement easily in Matlab is as follows:-

figure;
hold on
square = [2,-2; 2,2;-2,2;-2,-2];
sq_ = fill(square(:,1), square(:,2), 'g');
set(sq_, 'X', 17+square(:,1),'Y', 81+square(:,2));

How can we do the same in Python?

basically we are trying to move an object in the 2D plot according to our desire like animation. This can be extended to 3D also.

Please tell all ways of doing this in Python if there are multiple ways of doing this.