Apr-23-2022, 08:09 AM
hi,
I am trying to understand a piece of code, namely
I tried it on my own by running
Is this a special operation on an object generated from
Thanks!
I am trying to understand a piece of code, namely
import matplotlib.pyplot as plt
import numpy as np
expdat = np.genfromtxt(fname='expDat.txt', delimiter=',',
dtype=np.int, skip_header=1)[:,1:]
np.set_printoptions(edgeitems=5)
N = 5
plt.figure(figsize=(14,12))
for i in range(N):
for j in range(N):
plt.subplot(N, N, i*N+j+1)
plt.scatter(expdat[:,i], expdat[:,j])
if j==0:
plt.ylabel('$x_{}$'.format(i+1))
if i==N-1:
plt.xlabel('$x_{}$'.format(j+1))
plt.suptitle('pairwise scatter plots of the first {} variables (processes)'.format(N))
plt.show()I want to know what the notation expdat[:,i]does.
I tried it on my own by running
import matplotlib.pyplot as plt
N = 2
dat = [[1,2],[3,4]]
for i in range(N):
for j in range(N):
plt.subplot(N,N,i*N+j+1)
plt.scatter(dat[:,i],dat[:,j])
plt.show()However, it throws Error:TypeError: list indices must be integers or slices, not tuple.Is this a special operation on an object generated from
np.genfromtxt()?
Thanks!
