A single column [row:col]
a[:,y]
see the full list of numpy mathfunctions:
http://docs.scipy.org/doc/numpy/reference/routines.math.html
Heatmap!
Transpose an array:
data = data.transpose()
absolute value of matrix:
data = np.abs(data)
log10 of a matrix:
data = np.log10(data)
1.Read the matrix from the file (use np.loadtxt(“data.txt”))
2.Transpose the matrix
3.Apply a log10 transformation to all values
4.Copy row 11 to 15 and 18 (start counting at zero) (don’t forget n -1!)
5.Copy column 8 to columns 9 to 11 (start counting at zero) (don’t forget n -1!)
6.Transform all numbers to positive
7.Multiply all numbers between coordinates (2,3) and (18,7) by 20
8.Display the final result as a heatmap. It should be obvious if you got it right :P .
displaying a heatmap:
plt.pcolor(data)
plt.show()
selecting value, rows, columns...
data[x:y] (value)
data[x,:] (row)
data[:,y] (column)
making plots just a little prettier!
---- plots.py ----
import numpy as np
import matplotlib.pyplot as plt
# Compute the x and y coordinates for points on sine and cosine curves
x = np.arange(0, 3 * np.pi, 0.1)
y_sin = np.sin(x)
y_cos = np.cos(x)
# Plot the points using matplotlib
plt.plot(x, y_sin)
plt.plot(x, y_cos)
plt.xlabel('x axis label')
plt.ylabel('y axis label')
plt.title('Sine and Cosine')
plt.legend(['Sine', 'Cosine'])
plt.show()