I have the following simple code:
import numpy as np
import matplotlib.pyplot as plt
from scipy import linalg
for i in range(10):
M=np.array([[i**2,0],[0,i**3]]) # 2 x 2 matrix
eval,evec=np.linalg.eig(M)
# Plotting first and second eigenvalues
# Style 1
plt.plot(i,eval[0])
plt.plot(i,eval[1])
# Doesn't work
# Style 2
plt.plot(i,eval[0], '-r')
plt.plot(i,eval[1], '-b')
# Doesn't work
# Style 3
plt.plot(i,eval[0], 'ro-')
plt.plot(i,eval[1], 'bs')
# Does work
plt.xlabel('x')
plt.ylabel('y')
plt.savefig('plot.png')
plt.show()
While plotting with three different styles, only the third style (i.e. point or scatter plots) works successfully. Hence I have very limited customization options. Any way out?
Also, can these three differently styled plots be saved into three different files without creating separately three for-loops?