リストデータを使って単純な回転行列の結果をプロットしようとします。結果配列のある図は画面ダンプイメージと同じくらい多くのインデックスを持っています。 2番目のプロットは私のアトリビュート(ラインスタイルなど)と正確ではありません 私はプロットに間違った配列処理をしていますが、何がわからないのでしょうか。 コメントは歓迎します。前もって感謝します。matplotlibの配列の列データを持つ凡例が多すぎます
私のコードは以下の通りです。
import numpy as np
import matplotlib.pyplot as plt
theta = np.radians(30)
c, s = np.cos(theta), np.sin(theta)
R = np.matrix('{} {}; {} {}'.format(c, -s, s, c))
x = [-9, -8, -7, -6, -5, -4, -3, -2, -1,0,1,2,3,4,5,6,7,8,9]
y = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
line_b = [x,y]
result_a = R*np.array(line_b)
fig=plt.figure()
ax1 = fig.add_subplot(111)
plt.plot(line_b[0],line_b[1], color="blue", linewidth=2.5, linestyle="-", label='measured')
plt.plot(result_a[0], result_a[1], 'r*-', label='rotated')
ax1.set_ylim(-10,10)
ax1.set_xlim(-10,10)
plt.legend()
# axis center to move 0,0
ax1.spines['right'].set_color('none')
ax1.spines['top'].set_color('none')
ax1.xaxis.set_ticks_position('bottom')
ax1.spines['bottom'].set_position(('data',0))
ax1.yaxis.set_ticks_position('left')
ax1.spines['left'].set_position(('data',0))
plt.show()
おそらくresult_aは、あなたがそれを持っていることを期待する形状を有していないのですか? – CAB