我在Python中使用matplotlib时遇到问题。问题是我必须在X和Y轴的2D中旋转30°,45°,60°和120°而相反。在下面的代码中,有人可以给我一些如何旋转轴的提示。 注意:必须有2对轴可见,一对原始,黑色和旋转,在这种情况下是绿色。
import numpy as np
from mpl_toolkits.axes_grid1 import AxesGrid
import matplotlib.pyplot as plt
import matplotlib as mpl
from pylab import
axis([-5,5,-5,5]) #original axis x,y
axvline(x=0, ymin=0, linewidth=1, color='k')
axhline(y=0, xmin=0, linewidth=1, color='k')
t_start1 = axvline(x=0, ymin=0, linewidth=2, color='g') #rotated y coordinate
t_start2 = axhline(y=0, xmin=0, linewidth=2, color='g') #rotated x coordinate
scatter([0],[0],color="k",s=30,label="S = (0,0)")
scatter([2],[1],color="b",s=30,label="A = (2,1)")
scatter([2.23],[-0.13],color="r",s=40,label="A' = (2.23,-0.13)")
legend(loc=0)
xlabel('X')
ylabel('Y')
title('Rotation by 30° Right coordinate system ');
grid()
plt.show()
*